a.
Explanation of Solution
Program:
File name: “RetirementGoal.java”
//Import necessary header files
import java.util.Scanner;
//Define a class named RetirementGoal
public class RetirementGoal
{
//Define main method
public static void main (String[] args)
{
//Create an object for the Scanner class
Scanner input = new Scanner(System.in);
//Declare the variables
int years;
int saveAmount;
int total;
/*Prompt the user to enter the number of years the user
has until retirement */
System.out.print("How many years until retirement? >> ");
years = input.nextInt();
/*While condition if the user enters 0 or a negative number*/
while(years <= 0)
{
//Print the error message
System.out.println("Years cannot be 0 or negative");
//Reprompt the user to make a valid entry
System...
b.
Explanation of Solution
Program:
File name: “RetirementGoal2.java”
//Import necessary header files
import java.util.Scanner;
//Define a class named RetirementGoal2
public class RetirementGoal2
{
//Define main method
public static void main (String[] args)
{
//Create an object for the Scanner class
Scanner input = new Scanner(System.in);
//Declare the variables
int years;
int saveAmount;
int total;
final double RATE = 0.04;
/*Prompt the user to enter the number of years the user
has until retirement */
System.out.print("How many years until retirement? >> ");
years = input.nextInt();
/*While condition if the user enters 0 or a negative number*/
while(years <= 0)
{
//Print the error message
System.out.println("Years cannot be 0 or negative");
//Reprompt the user to make a valid entry
System.out.print("Please renter years >> ");
years = input.nextInt();
}
/*Prompt the user to enter the amount of money the user can save annually*/
System.out.print("How much can you save annually? >> ");
saveAmount = input.nextInt();
/*While condition if the user enters 0 or a negative number*/
while(saveAmount <= 0)
{
//Print the error message
System...
Trending nowThis is a popular solution!
Chapter 6 Solutions
JAVA PROGRAM(LL)+MINDTAP (1 TERM) V2.0
- Write an application that allows a user to enter any number of student test scores until the user enters 999. If the score entered is less than 0 or more than 100, display an appropriate message and do not use the score. After all the scores have been entered, display the number of scores entered, the highest score, the lowest score, and the arithmetic average. Save the file as TestScoreStatistics.cpp.arrow_forwardCreate an application that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows:1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer’s choice yet.)2. The user selects his or her choice of rock, paper, or scissors. To get this input you can use Button controls, or clickable PictureBox controls displaying some of the artwork that you will find in the student sample files.3. The computer’s choice is displayed.4. A winner is selected according to the following rules:• If one player chooses rock and the other player chooses scissors, then rock wins. (Rock smashes scissors.)• If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.)• If one player chooses…arrow_forwardLatest version of NetBeans IDE Java Development Kit (JDK) 8 Create a folder named Dahan_yoon in your local Create a new project named LabExer5A. Set the project location to your own The program shall: generate a random number from 1 to 50 for a player to guess; display a message that indicates whether the player’s guess is correct, too low, or too high; and prompt the user to keep on guessing until the correct value is entered Create a try-catch structure that will handle two (2) exceptions. These are when the user inputs the following: a number that is out of range (1 – 50) a letter or any non-numeric character Prompt the user so that he can guess again if an exception is Display the number of total Note: An invalid input (when an exception is thrown) is not considered a valid guess or attempt.arrow_forward
- Here is the question: Write an application that prompts a user for the number of years the user has until retirement and then the amount of money the user can save annually. If the user enters 0 or a negative number for either value, reprompt the user until valid entries are made. Assume that no interest is earned on the money. Display the amount of money the user will have at retirement.arrow_forwardCreate the following program: In this question you are asked to write a lottery game application. Your program must first display a welcome message/banner asking the human player for his/her given name. Generate a random number between 0 and 999, which you are to store in a single variable (int). Allow the user to guess a three digit number between 0 and 999, which you are also to store in a single variable of type int. Compare the user’s guess to the random number and display a message that includes the user’s name, user’s guess, the randomly determined three-digit number and the amount of money the user has won as follows: Matching digits Awards Any one matching. $10 Two matching. $100 Three matching not in order. $1000 Three matching in exact order. $1,000,000 No matches. $0 Make sure that your application accommodates repeated…arrow_forwardWrite an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than 0 or more than 10, display Score must be between 10 and 0 and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average. An example of the program is shown below: Enter a score >> 6 Enter another score or 99 to quit >> 7 Enter another score or 99 to quit >> 9 Enter another score or 99 to quit >> 7 Enter another score or 99 to quit >> 99 4 valid scores were entered Highest was 9 Lowest was 6 Average was 7.25 PLEASE WRITE A JAVA CODE import java.util.*; public class QuizScoreStatistics { public static void main (String args[]) { // Write your code here } }arrow_forward
- Write an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than O or more than 10, display Score must be between 10 and O and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average. An example of the program is shown below: Enter a score >> 6 Enter another score or 99 to quit >>» 7 Enter another score or 99 to quit >» 9 Enter another score or 99 to quit >» 7 Enter another score or 99 to quit >> 99 4 valid scores were entered Highest was 9 Lowest was 6 Average was 7.25arrow_forwardwrite an application that creates a quiz. the quiz should contain at least five questions about a hobby, popular music, astronomy, or any other personal interest. each question should be a multiple choice question with at least four answer options. when the user answers the question correctly display a congratulatory message. if the user responds to a question incorrectly display an appropriate message as well as the correct answer. at the end of the quiz display the number of correct and incorrect answers and the percentage of the correct answers. in javaarrow_forward3. Solar Panel InstallationThe Megawatt solar panel company installs solar panels on home rooftops. The base installation charge of $2,000 includes two panels. The charge for each additional panel is $300. The normal waiting time for installation is two weeks, but customers can pay an express charge of 5% of the total cost to reduce this time. Create an application that collects the required information from the user and calculates the charges for the installation.The user should input the following information: first name, last name, phone, number of panels, deposit amount, and a check box for the express installation option. When the user clicks a button to view the charges, display a group box containing the following information: base installation charge, cost of installing additional panels, total installation cost, deposit amount, and balance due.Error checking should include the following criteria:• The name and phone fields cannot be blank• The number of panels must be an…arrow_forward
- Write an application that asks a user to enter an integer. Display a statement that indicates whether the integer is even or odd.arrow_forward99 question Reza Enterprises sells tickets for buses, tours, and other travel services. Because Reza frequently mistypes long ticket numbers, Reza Enterprises has asked his students to write an application that shows if a ticket is invalid. Your application/program tells the ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you lose the last digit of the number, then divide by 7, the remainder of the division is exactly the same to the last dropped digit. This process is shown below: Step 1: Enter the ticket number; for example 123454 Step 2: Remove the last digit, leaving 12345 Step 3: Determine the remainder when the ticket number from step 2 is divided by 7. In this case, 12345 divided by 7 leaves a remainder of 4. Step 4: Display a message to the ticket agent indicating whether the ticket number is valid or not. If the ticket number is valid, save the number to a .txt file called “tickets.txt” and.arrow_forwardIn javas coding please Write a program that opens the salesdat.txt file and processes it contents. The program should display the following per store: The total sales for each week. (Should print 5 values - one for each week). The average daily sales for each week. (Should print 5 values - one for each week). The total sales for all the weeks. (Should print 1 value) The average weekly sales. (Should print 1 value) The week with the highest amount in sales. (Should print 1 week #) The week with the lowest amount in sales. (Should print 1 week #) All Values (Total Sales, Average Daily Sales for Each Week, Total Sales for all Weeks, Average Weekly Sales, Highest Amount in Sales, Lowest Amount in Sales) The file contains the dollars amount of sales that a retail store made each day for a number of weeks. Each line in the file contains thirty five numbers, which are sales numbers for five weeks. The number are separated by space. Each line in the file represents a separate store.…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,