EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 6, Problem 10PE

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...

Blurred answer
Students have asked these similar questions
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.
● Create a simple calculator application that asks a user to enter twonumbers and the operation (e.g. +, -, x, etc.) that they’d like to perform onthe numbers. Display the answer to the equation. Every equation enteredby the user should be written to a text file. Use defensive programming towrite this program in a manner that is robust and handles unexpectedevents and user inputs. Now extend your program to give the user the option to either enter twonumbers and an operator, like before, or to read all of the equations froma new txt file (the user should add the name of the txt file as an input) andprint out all of the equations together with the results. Use defensiveprogramming to ensure that the program does not crash if the file doesnot exist and that the user is prompted again to enter the name of the file.
Please code in  javas, thank you 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. Please…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY