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
Select the correct locations on the image. Adrian wants to delve into database administration. Which certifications would help h
marta [7]

Answer:

Oracle DBA and MCITP

6 0
3 years ago
The help desk received a call from a user who cannot get any print jobs to print on the locally shared printer. While questionin
iragen [17]

Answer:

Power cycle the printer

Explanation:

To power cycle a device means to turn it off and turn it back on again.This might mean switching the power to OFF and then ON again or may require physically unplugging the device and then plugging it back in again.Power cycling the device erases the RAM and allows it to boot up with fresh information.

Typically it is a good idea to wait 5 to 10 seconds before turning the device back on to make sure it has chance to fully reset.

3 0
3 years ago
Read 2 more answers
Everyone should try to be an NFL quarterback because they earn so much money. True or False
In-s [12.5K]
No. It is statistically unlikely to even make it into the NFL. Pursuing this is not the best idea.
6 0
4 years ago
Read 2 more answers
Consider the Palindrom class discussed in class. Which of the following is true? It uses one stack and one queue to find out if
yawa3891 [41]

Answer:

It uses a recursive method to find out if a string is a palindrome

Explanation:

Palindrome is a word or a sequence which is read same as backward as forwards. There are various method to find a palindrome. Palindrome can be determined recursively by identifying the first and last letters of the word. These first and last letter should be same. If they are same then the word or sequence is palindrome.

5 0
3 years ago
I need to know the answer to this question
RoseWind [281]

It's D because all of this are TRUE.

3 0
3 years ago
Other questions:
  • Carl sent an e-mail to more than three thousand employees about a software update. The employees need to prepare for this update
    7·2 answers
  • Nathan notices his computer System is slowing down when he tries to copy documents to it he also gets a prompt I warned him that
    7·1 answer
  • How do you adjust the shear of a shape?
    10·2 answers
  • When creating a new user in linux, after entering the name, the username box:?
    9·1 answer
  • Analyze the following code:
    8·1 answer
  • _______is a network of physical objects embedded with sensors, processors, software and network connectivity capability to enabl
    6·1 answer
  • Improvements in technology make the world seem larger to people.<br> a. True<br> b. False
    6·2 answers
  • PLEASE HELP!!!
    12·1 answer
  • Name 3 things that you use daily that are considered computers?
    6·1 answer
  • Variables that can take only 2 variables are referred to as which one of the following?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!