Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write COMMENT FOR each Section. post ScreenShot of output it must be done using JGRASP Explain the program to user Purpose Calculate savings and

Please write COMMENT FOR each Section.

post ScreenShot of output

it must be done using JGRASP

Explain the program to user

Purpose Calculate savings and investment amounts using Java classes.

In this order: opy of the source code with line numbers of both source files (main program and the class), and a screen print showing the output. You will type in three numbers that are the gross pay, savings rate and IRA investment rate, then show those numbers and the output.

Java Topics Java classes, if statements, calculating with percentages.

Specification

Write a separate Java class for calculations named YourName_S_09_Calc that will have three private instance variables of type double for the gross pay, savings rate and IRA investment rate. Note that any calculated fields are NOT private variables in this class. The Java class should contain these methods:

A constructor that initializes the instance variables to default values of 0. This Constructor has no parameters

A constructor with three parameters that initializes the instance variables to the parameter values. Note this constructor is not used in the assignment.

A method for the user to input the gross pay, savings rate and IRA investment rate. Include prompts. Allow values only greater than 0

A method that outputs the input values along with appropriate messages

A method that returns the savings amount

A method that returns the IRA investment amount

This class should be placed in a file that is separate from the class containing the main program. Note: Only method #2 above has parameters. As is typical in a class, the rest of the class methods do not have parameters.

Write a Java application main program in Java file YourName_S_09 in the order specified below. This code will be in a .java file that is separate from the one for the YourName_S_09_Calc class above. Note that the main method should have savings amount and IRA investment amount as local variables. It should NOT have declarations for the gross pay, savings rate and IRA investment rate.

You can use global scope only for the Toolkit. All other declarations, including creating an instance of the calculation class, should be local to the main program. (If necessary, of course, you can declare local variables in the main programs methods as needed.)

Call a void method in the main program that outputs an explanation of what the program does. Include in the explanation that this program uses a class for caclulations and include your name.

Get the gross pay, savings rate and IRA investment rate from the user. Use the method from the calculation class.

Calculate the savings amount. Use the method from calculation class.

Calculate the IRA investment amount. Use the method from the calculation class.

Use a void method to output, with appropriate messages: the gross pay, savings rate and IRA investment rate (use the method from the calculation class), the savings amount, the IRA investment amount and the sum of the latter two.

The style of your code should be similar to that of Interactive Average with a Class. Be sure to include comments programmer identification, assignment number, section number as appropriate, purpose, and a brief explanation of the methods should appear in the header comment, along with the vocabulary word and quote. Include an explanation for all variables, parameters and methods.

Assignment #2

Purpose: Calculate gross pay, savings and investment.

Due and re-doable dates are per the Course at a Glance.

Write a Java program named as usual, Main_02.java, to execute the steps below. Write your program so that the steps are done in the order listed. Use the program you wrote for Assignment 1 as a model for this program.

1. Prompt for the input of three real numbers type double which are someones gross pay, savings rate percentage and IRA investment rate percentage. Note you are entering percentages like 10.0, and not the decimal equivalent. (How will you convert the rates to numbers you can use in calculations?) Read the three numbers and dont do any error checking. Use the style of Program Assignment #1 for the input.

2. From the input, calculate the amount that goes into the savings account, the amount that goes into the IRA investment account and the total that goes into both accounts. What input values will you use to test that the program works?

Output, with appropriate messages, one per line:

The gross pay, savings percentage rate, IRA investment rate, amount that goes into savings, amount that goes into the IRA investment account, and the total of what goes into both accounts.

Use the text below when prompting for numbers and displaying the output. Include a space after each colon. The first three lines are prompts for input values. The remaining lines are displayed using System.out.println(). ZyLabs will be matching text and numbers, so be sure your text exactly matches the text shown below.

Enter the gross pay:

Enter the savings rate %:

Enter the IRA rate %:

Gross pay:

Savings rate %:

Savings amount:

IRA rate %:

IRA investment amount:

Total of savings and IRA amounts:

The style of the program should be similar to that of Program Assignment #1. Include the comments section as at the top of assignment 1: programmer identification, purpose, version of Java used, vocabulary word and quotation. Include comments that explain variables, and some comments in the body of the code (divide the code into blocks and comment each block).

Note: when testing your program, also run it with numbers that are not reasonable gross pay, savings percentage rates and IRA investment numbers. Examples are gross pay less than 0 or percentages less than 0. What do you observe?

Assignment #5

Calculate savings using methods. This assignment builds on Assignment #2.

Due Date Per the Course at a Glance. Can be resubmitted.

Java Topics methods, if statements, calculating with percentages.

Write a Java program and methods in the order listed below.

Declare the variables as type double for the gross pay, savings rate, IRA investment rate, savings amount, IRA investment amount and the total of the two amounts inside the main method and use them as appropriate when you call methods.

Call a void method that will output an explanation of what the program does. The explanation is this statement:

This program calculates savings amounts using methods.

2. Input these three numbers: gross pay, savings rate and IRA investment rate. Use one method to read and return a value so you will call this method three times. When a number is input, ensure it is greater than 0. Note: use the System.out.print style of Assignment #2 to prompt for input, not JOptionPane as in Assignment #3. Use the prompts exactly as shown below in step 4. If an input value is 0 or less, use this message:

Please enter a value greater than 0.

and prompt again for the value you are requesting.

Calculate the savings amount and IRA investment amounts using one method for both calculations. The method will have two parameters, the gross pay and the respective percentage rate. In the main program, use a third variable to calculate the total of these two amounts.

Use a void method to output, with the messages below: the three values that were inputted, the savings amount, IRA investment amount, and the total of the two amounts.

Note that this method requires six parameters. Output all decimal results to one or two places, depending on whether the result is a rate or a dollar amount, respectively. Using a gross pay of $10,000, a savings rate of 10% and an IRA rate of 5%, the messages are:

Enter the gross pay: 10000

Enter the savings rate %: 10

Enter the IRA rate: 5

Gross pay: 10,000.00

Savings rate: 10.0%

Savings amount: 1,000.00

IRA rate: 5.0%

IRA amount: 500.00

Total of amounts: 1,500.00

As before, include comments programmer identification, assignment number, section, purpose, the explanation for all variables, parameters, and methods, and the vocabulary word and quote. See the documentation standards.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Ai And The Lottery Defying Odds With Intelligent Prediction

Authors: Gary Covella Ph D

1st Edition

B0CND1ZB98, 979-8223302568

More Books

Students also viewed these Databases questions