Question: Stuck on for loops for this computer science lab. The assigment is Read in starting value in account, yearly interest rate and number of months

Stuck on for loops for this computer science lab. The assigment is

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.

The code I have so far is

package Labs;

import java.util.Scanner;

public class Lab08 {

public static void main(String[] args) { //Create scanner Scanner getInfo = new Scanner(System.in); //variables double accountAmount, monthlyInterestRate; double yearlyInterest, oneYear, accountBalance; //read in values print statement System.out.println("Please enter amount in account "); accountAmount = getInfo.nextDouble(); //read in values for amount in account and monthly interest rate (yearly interest rate / 12 months System.out.println("Enter yearly interest in floating point "); yearlyInterest = getInfo.nextDouble(); System.out.println("Enter in the amount of months in a year "); oneYear = getInfo.nextDouble(); //close scanner getInfo.close(); //print statement for interest rate method and calculation for interest in account monthlyInterestRate = calcMonthlyDoubles(yearlyInterest, oneYear); System.out.println("The monthly interest is "+monthlyInterestRate); accountBalance = calcInterestDoubles(accountAmount, monthlyInterestRate); System.out.println("Account balance after interest rate is "+ accountBalance); }//end of main method public static double calcMonthlyDoubles(double yearlyInterest, double oneYear) { double result; result = yearlyInterest / oneYear; return result; }//end of calculateMonthly method

public static double calcInterestDoubles(double accountAmount, double monthlyInterestRate) { double result; result = accountAmount + monthlyInterestRate*accountAmount; return result; }//end of calcInterest method }

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 Databases Questions!