1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Drupady [299]
3 years ago
11

Create class SavingsAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders.

Each object of the class contains a private instance variable savingsBalance indicating the amount the saver currently has on deposit. Provide method calculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12- this interest should be added to savingsBalance. Provide a static method setInterestRate that sets the annualInterestRate to a new value. There should also be a method setSavingsBalance to set the initial savings balance for a new saver or you can do it through a constructor.
Write a program to test class SavingsAccount. Instantiate two SavingsAccount objects, saver1 and saver2, with balances of $2000.00 and $3000.00, respectively. Set annualInterestRate to 4%, then calculate the monthly interest for each 12 months and print the new balances for both savers. Next, set the annualInterestRate to 5%, calculate the next month's interest and print the new balances for both savers.

If you run this java file right now, it only prints out the amount for 1 month. How can you make my program so that it prints the amount for 13 months?

It should print out

Month 1: 2006.67

Month 2: 2013.36

Month 3: 2020.07

Month 4: 2026.80

etc.

after 12 month, change the rate to be 5 percent
Computers and Technology
1 answer:
Anika [276]3 years ago
7 0

Answer:

import java.util.*;

public class Main{

public static double calculateMonthlyInterest(double annualInterestRate, double savingsBalance){

    double monthlyInterest = annualInterestRate * savingsBalance / 12;

    return monthlyInterest; }

public static double setInterestRate (){

    Scanner input = new Scanner(System.in);

    System.out.print("Interest Rate: ");

    double rate = input.nextDouble();

    return rate; }

public static double setSavingsBalance(double monthlyInterest, double savingsBalance){

    return (monthlyInterest+savingsBalance); }

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

    System.out.print("Savings Balance: ");

    double savingsBalance = input.nextDouble();

 double annualInterestRate = setInterestRate();

 for(int i = 1;i<=12;i++){

 double monthlyInterest = calculateMonthlyInterest(annualInterestRate,savingsBalance);

 savingsBalance = setSavingsBalance(monthlyInterest,savingsBalance);

 System.out.printf("Month "+i+"  %.2f %n",savingsBalance);

 }

}

}

Explanation:

<em>The java file stated in the question is not attached to the question; So, I answered the question from the scratch.</em>

<em>See attachment for program file where I used comments to explain some lines</em>

Download txt
You might be interested in
I need help <br> Match each words with its definition!!!<br> Please helpppppppp
satela [25.4K]

Answer:

Top to bottom Answer in order

#1 hardskills

#2 goal

#3 value

#4 soft skills

#5 on the job training

#6 self training

6 0
3 years ago
3. Which property is used to select full Row of data grid view
Tju [1.3M]

Answer:

I think a is correct answer.

4 0
3 years ago
Jamal is installing new software and would like a step-by-step guide to teach him how. Which resource would be best, and why?
ratelena [41]
The answer is D because it will explain and show how to install the software.
3 0
3 years ago
Read 2 more answers
Which activity is a case of identity theft
dezoksy [38]
<span>Criminal identity theft (posing as another person when apprehended for a crime)Financial identity theft (using another's identity to obtain credit, goods and services)Identity cloning (using another's information to assume his or her identity in daily life)Medical identity theft (using another's identity to obtain medical care or drugs)<span>Child identity theft]


cite: wikipedia</span></span>
4 0
3 years ago
Read 2 more answers
What is your favorite anime?
ira [324]

Answer:

Fullmetal Alchemist: Brotherhood (160,975)

Explanation:

Fullmetal Alchemist: Brotherhood (160,975)

6 0
3 years ago
Other questions:
  • What key combination in excel takes you back to the first cell
    7·1 answer
  • How many points are in an inch? <br> A 24<br> B 50<br> C 72<br> D 100
    5·1 answer
  • Why are advanced features helpful when businesses use spreadsheets
    5·1 answer
  • Write two cin statements to get input values into birthMonth and birthYear. Then write a statement to output the month, a dash,
    11·1 answer
  • Which type of loan is based on financial need
    6·1 answer
  • Algorithm and flowchart:- find the product of two number (a and b)​
    11·1 answer
  • What happens to a message when it is deleted?
    11·1 answer
  • Question 2 of 3
    7·2 answers
  • HELP PLEASE!!!! Which development method is best explained in this way: developing a system through repeated cycles and smaller
    10·1 answer
  • Vivek wants to save the data about his grocery store in a single table. Which among the following type of databases is used in t
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!