Question

Develop an algorithm for computing the month - by -month balance in your saving account. You...

Develop an algorithm for computing the month - by -month balance in your saving account. You can make one transaction — a deposit or a withdrawal

— each month. Interest is added to the account at the beginning of each month. The monthly interest rate is the yearly percentage rate 7%.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

import java.lang.*;
import java.io.*;

class SavingsAccount
{
String customerName;
long accountNumber;
float interestRate;
double balance;
double openingBalance;
int numberOfWithdrawl;
double totalDepositMoney;
double totalWithdrawMoney;

SavingsAccount(double startingBalance,float iRate)
  {
   this.openingBalance=startingBalance;
   this.balance=startingBalance;
   this.interestRate=iRate;
  }
SavingsAccount()
  {
   numberOfWithdrawl=0;
   totalDepositMoney=0;
   totalWithdrawMoney=0;
  }
public void withdraw(double amount)
  {
   if(numberOfWithdrawl>2)
    balance=balance-0.5;

   if(balance>25)
    {
    balance=balance-amount;
    numberOfWithdrawl +=1;
    totalWithdrawMoney =totalWithdrawMoney+amount;
    displayWithdraw(amount);
    }
   else
    {
    System.out.println("You are unable to Withdraw");
    }
   if(numberOfWithdrawl>2)
    balance=balance-0.5;
  
  }

public void deposit(double amount)
  {
   totalDepositMoney=totalDepositMoney+amount;
   balance=balance+amount;
   displayDeposit(amount);
  }
public void setData(String name,long number)
  {
   customerName=name;
   accountNumber=number;
  }
public void displayOpenAccount()
  {
  display();
  System.out.println("Begining Balance:"+balance);
  System.out.println("Annual Interest Rate:"+interestRate);  
  }
public void displayDeposit(double amount)
  {
  display();
  System.out.println("Deposit Amount:"+amount);
  }
public void displayWithdraw(double amount)
  {
  display();
  System.out.println("WithDrawl Amount:"+amount);
  }

public void display()
  {
  System.out.println("Customer Name :"+customerName);
  System.out.println("Account Number:"+accountNumber);
  }
public void monthlyStatement()
  {
  double interest=(balance*interestRate)/100;
  System.out.println("The Start Balance is :"+openingBalance);
  System.out.println("The total amount of deposits:"+totalDepositMoney);
  System.out.println("The total amount of withdrawls:"+totalWithdrawMoney);
  System.out.println("Interest Earned in the month:"+interest);
  
  }


}

public class SavingAccountTester
{
public static void main(String args[]) throws Exception
  {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                        SavingsAccount sb=new SavingsAccount();
  do
  {
   System.out.println("----MENU----");
   System.out.println("1.Open Account");
   System.out.println("2.Deposit");
   System.out.println("3.Withdraw");
   System.out.println("4.Monthly Statement");
   System.out.println("0.Exit");
   
   int choice=Integer.parseInt(br.readLine());
   switch(choice)
    {
    case 1: System.out.print("Enter Customer Name:");
     String cname=br.readLine();
     System.out.print("\nEnter Account Nuber:");
     long ano=Long.parseLong(br.readLine());
     System.out.print("\nOpening Balance:");
     double amount=Double.parseDouble(br.readLine());
     System.out.print("\nInterest Rate:");
     float irate=Float.parseFloat(br.readLine());
     System.out.println();
     sb=new SavingsAccount(amount,irate);
     sb.setData(cname,ano);
     sb.displayOpenAccount();
     break;
    case 2: System.out.print("Enter Amount to Deposit:");
     double damount=Double.parseDouble(br.readLine());
     sb.deposit(damount);
     break;
    case 3: System.out.print("Enter Amount to Withdraw:");
     double wamount=Double.parseDouble(br.readLine());
     break;
    case 4: sb.monthlyStatement();
     break;
    case 0: System.exit(0);
    default:System.out.println("Invalid Choice");
    }
  }while(true);
}
}

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Develop an algorithm for computing the month - by -month balance in your saving account. You...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please help solve this problem 4. You and a friend are saving money for a summer...

    please help solve this problem 4. You and a friend are saving money for a summer in Europe after you graduate. You have each been depositing $500 each month into an interest bearing account so you can make 4 monthly withdrawals to pay for your trip. This investment account provides an annual interest rate of 5%, compounded monthly. a. Will you have saved enough money for the trip? b. If not, how much will you need to add to your...

  • (5) You have $130,000 today and want to deposit it into a saving account at Houston...

    (5) You have $130,000 today and want to deposit it into a saving account at Houston Cougar Bank. The clerk at the bank says if you make a deposit today, then your balance in 6 years will be $190,000. Assume the bank computes the interest rate compounded monthly. What is the interest rate per month offered by the bank? (Hint : This is similar to, fundamentally the same as, the question (2).) 1.0.4090 2. 0.43% 3. 0.47% 4. 0.50% 5.0.53%

  • You decide to open a retirement account at your local bank that pays 10%/year/month (10% per...

    You decide to open a retirement account at your local bank that pays 10%/year/month (10% per year compounded monthly). For the next 20 years, you will deposit $300 per month into the account, with all deposits and withdrawals occurring at month’s end. On the day of the last deposit, you will retire. Your expenses during the first year of retirement will be covered by your company’s retirement plan. As such, your first withdrawal from your retirement account will occur on...

  • Develop a VI that computes the balance of a bank account (compounded yearly) at a given...

    Develop a VI that computes the balance of a bank account (compounded yearly) at a given interest rate with yearly monetary additions. Use the following base equation: X=P1+in Where X is end of year account balance, P is the initial account balance, i is the interest rate, and n is the number of years. NOTE: This equation does not account for additional yearly deposits! It is your job to figure out how to include that portion of the equation. User...

  • 3. Suppose you have money invested in a savings monthly. You also make a deposit of D dollars once each month, and you...

    3. Suppose you have money invested in a savings monthly. You also make a deposit of D dollars once each month, and you make a withdrawal of P percent of the balance each month. (a) Sketch a compartmental diagram for the amount of money in the account. (b) Write a difference equation (or recurrence relation) for this model (c) Find the fixed points (d) Suppose that r=0.03 and P 0.07 . Find the amount D that you should deposit each...

  • Suppose you are exactly 25 years old and you are planning to save for your retirement...

    Suppose you are exactly 25 years old and you are planning to save for your retirement which will happen in 40 years. You plan to deposit equal amount at the beginning of each month in your retirement account with the first saving made today. Assume the retirement account pays you 6% p.a. compounded monthly. (a) If you would like to have $1,000,000 in your retirement account 40 years later when you are retired, how much will you have to deposit...

  • Taylor has a retirement account that pays 4% per year compounded monthly. Every month for 20...

    Taylor has a retirement account that pays 4% per year compounded monthly. Every month for 20 years, Taylor deposits $444, with the first deposit at the end of month 1 The day the last deposit is made, the interest rate increases to 6% per year compounded monthly. During retirement, Taylor plans to make equal monthly withdrawals for 15 years, thus depleting the account. The first withdrawal occurs one month after the last deposit. How much can be withdrawn each month?

  • 8-One year from now, you deposit $300 in a savings account. You deposit $1,800 the next...

    8-One year from now, you deposit $300 in a savings account. You deposit $1,800 the next year. Then you wait two more years (until 4 years from now) and deposit $1,000. If your account always earns 6% annual interest and you make no withdrawals, how much will be in the account 11 years from now? 9-You deposit $5000 for 5 years at 4% annual interest. In 5 years, you add $15,000 to your account, but the rate on your account...

  • Answer Question 5 (1 point) You decide to begin saving for your retirement. Each month you...

    Answer Question 5 (1 point) You decide to begin saving for your retirement. Each month you will deposit $400 in to an account that earns J12 = 10%. How much money will you have in 6 years if your first payment in one month? Your Answer: Answer Question 6 (1 point) You decide to begin saving for a vacation. Each month you will deposit $250 in to a account that earns J12 = 10%. How much interest will you earn...

  • 7. Today you inherit an account with a balance of $5400. For a while you don't...

    7. Today you inherit an account with a balance of $5400. For a while you don't do anything with the account but it continues to accrue interest. Exactly 21 months from today you start an ambitious savings plan and deposit $190 into the account. You plan to deposit that much each month. Exactly 45 months from today you reconsider your plan, make your last deposit, and make no additional deposits. You nonetheless leave the account alone and it continues to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT