Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package test: import java.util.Scanner; public class IntrestRate { public static void main(String[] args) { double saving,interestRate,first,second,third,fourth; // variable declaration Scanner sc = new Scanner(System.in); //

package test: import java.util.Scanner; public class IntrestRate { public static void main(String[] args) { double saving,interestRate,first,second,third,fourth; // variable declaration Scanner sc = new Scanner(System.in); // Scanner declaration System.out.print("Enter initial saving value:"); saving=sc.nextDouble(); // Accept savings System.out.print("Enter interest rate:"); interestRate=sc.nextDouble(); // Accept interest Rate first = saving + (interestRate/100/12*saving) ; // account after 1 month second = first + (interestRate/12/100*first);// account after 2 months third = second + (interestRate/12/100*second);// account after 3 months fourth = third + (interestRate/12/100*third); // account after 4 months System.out.print("Account after 4 months is "+fourth); System.out.println(); } }?

*******************************

This problem requires modification of the program above using methods in it.

Read in starting value in account, yearly interest rate and number of months

Create method called calculateMonthly that gets yearly interest rate and calculates monthly rate and assign it to a monthly interest rate variable

Create a method called CalcInterest and pass the current value in account and monthly interest rate. It should return new amount in the savings account .

Create loop that executes the number of months and calls the method each month returning the new value in the account

When loop is done print the amount in the account

Test it for 4 months with starting value of $100 and 12% yearly rate. Should get same result as previous lab

Also test it for 3 months with 0% yearly interest rate.

programing language Java.

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

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

I didnt know who to talk to.

Answered: 1 week ago

Question

6. Testing equipment that will be used in instruction.

Answered: 1 week ago