Question: this assignment, you will write a Java program that: 1 . Calculates total weekly savings with and without interest. Save the file as LastNameFirstNameCIT 1

this assignment, you will write a Java program that:
1. Calculates total weekly savings with and without interest. Save the
file as LastNameFirstNameCIT130Hw5.java
1- Use while loop for validaion a- Prompt the user for the number of weeks. The number should
not be negative and not more than 50 weeks
(use another while loop, inner loop)
If the number is negative or zero or more than 50
An error message will display and ask the user to enter the number of weeks again Close the
inner while loop b- Enter how much they can save weekly.
This will be the weekly savings amount (e.g., $50 per week).
Multiply the number of weeks by the weekly savings to get the total savings without interest.
Display the result: you can use printf
For example: "If the user enters a valid number of weeks 2
And the user enter amount to save weekly $50 without interest,
Total saving will be 2x50= $100."
Set the total saving with interest to zero.
To calculate the total savings with interest, apply the interest rate of 2% after each week's
savings is added. Use for loop
Add the weekly savings, then increase the total by 2%(the interest rate) each week.
Repeat this process for the number of weeks entered by the user.
Display the total savings with interest: use printf
For example: "If you save $50 for 2 weeks, with 2% weekly interest, you will have $103.02." Inside
a for loop
First iteration
Total Saving with interest = Total Saving with interest + weekly savings =0+50=50.00
Total Saving with interest = Total Saving with interest +(Total Saving with interest* interest rate)
=50.00+(50.00*.02)=51.00
Second iteration
Total Saving with interest = Total Saving with interest + weekly savings =51.00+50=101.00 Total
Saving with interest = Total Saving with interest +(Total Saving with interest* interest rate)=
101.00+(101.00*.02)=103.02
c- Ask the user if would like to try again yes or no. Yes and No are Strings
If the user enters yes, then will be asked to enter a valid number of weeks, if the user enters
no, then will assign a valid number to false The program will end
Note: Please pay attention to the number of decimal places in the output values.
Also, it should not matter if the user enters Yes, yes, or YES; the same applies to no.
Sample Run:
How many weeks do you plan to save? >>-2
Weeks cannot be 0 or negative or more than 50. Please enter weeks.
55

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!