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
What is the difference between a crosstab query and a subquery?
shtirl [24]

Answer:

A crosstab query is a type of select query. ... When you create a crosstab query, you specify which fields contain row headings, which field contains column headings, and which field contains values to summarize. You can use only one field each when you specify column headings and values to summarize.

Explanation:

8 0
3 years ago
Read 2 more answers
Databases, authentication, and user accounts are all part of a website's ______________.
Varvara68 [4.7K]

Answer:

The answer is "Backend".

Explanation:

The Backend Development applies to just the webserver side when they concentrate mostly on how well the site functions. The website generally includes 3 sections consist of all this web design: a client, program, or server. The Backend user codes are the information provided by the database to both the web browser.

5 0
3 years ago
Example 4-1: The styles for the main content of an HTML document main { clear: left; } main h1 { font-size: 170%; } main h2 { fo
jek_recluse [69]

Answer:

The clear property stops floating of the main element to the right of the preceding block elements

Explanation:

The clear property specifies that which sides of the elements floating element are not allowed to be float.

It returns or sets the positions of an element in relation to the floating objects. If an element can be fitted horizontally in space next to other elements which is floated.

Syntax:

clear: none | left | right | both | initial;

6 0
3 years ago
The diagram shows the positions of the Sun, Earth, and Moon during each moon phase. When viewed from Earth, at what point does t
goldfiish [28.3K]

Answer:

B

Explanation:

when it is on the same side of Earth as the Sun because it appears all black because of the shadow

7 0
2 years ago
If a stadium pays $20,000 for labor and $13,000 for parking, what is the stadium's profit margin if the game generates $206,000
Temka [501]

Answer:$30,300

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Each phase of the system development life cycle is accomplished as a discrete, separate step. (1 point) (Points : 1.5) True
    7·1 answer
  • What are the best apps to learn coding
    15·2 answers
  • How can i appear offline without fb messenger saying "last active 1 minute ago"?
    5·1 answer
  • O que é sistema distribuido?
    8·1 answer
  • Write a program that calculates the occupancy rate for each floor of a hotel. The program should start by asking for the number
    10·1 answer
  • How does inertia affect a person who is not wearing a seatbelt during a collision
    8·1 answer
  • Files and folders in UNIX can be removed using the
    8·1 answer
  • Three Strings someone help
    15·1 answer
  • What type of error occurred??
    10·1 answer
  • Re:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!