0% found this document useful (0 votes)
76 views1 page

RunSavingsAccount Java

This Java program defines a RunSavingsAccount class to model a savings account. It allows the user to input an interest rate, make deposits and withdrawals, and displays the updated balance. Based on user input, it will perform another deposit calculation including interest, or a withdrawal validation and balance update.

Uploaded by

baldo baldovino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views1 page

RunSavingsAccount Java

This Java program defines a RunSavingsAccount class to model a savings account. It allows the user to input an interest rate, make deposits and withdrawals, and displays the updated balance. Based on user input, it will perform another deposit calculation including interest, or a withdrawal validation and balance update.

Uploaded by

baldo baldovino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

Scanner;

public class RunSavingsAccount {

static Scanner user = new Scanner(System.in);


public static void main (String []args){
RunSavingsAccount savings = new RunSavingsAccount();

System.out.print("Please enter the Interest Rate: ");


double newRate = user.nextDouble();
RunSavingsAccount.setInterestRate(newRate);

System.out.print("Please type the amount you want to deposit: ");


double amount = user.nextDouble();
savings.deposit(amount);

System.out.println("Your balance is " + " " + savings.getBalance());


System.out.print("Press D for another deposit or W withdraw: ");
String Press = user.next();

if(Press.equalsIgnoreCase("d")){
System.out.print("Please enter the amount for another deposit: ");
int anotherdeposit = user.nextInt();
savings.deposit(anotherdeposit);
if(savings.getBalance() > 1000){
double gBalance = savings.getBalance() *
RunSavingsAccount.setInterestRate(newRate);
double fBalance = savings.getBalance() + gBalance;
System.out.println("Your new balance " + "" + fBalance);
}

else if (Press.equalsIgnoreCase("w")){
System.out.print("Please enter the amount you want to withdraw: ");
double withdraw1 = user.nextDouble();
savings.withdraw(withdraw1);
if(savings.withdraw(withdraw1) > 0){
double WithDraw = amount - withdraw1;
System.out.println("Your new balance is " + WithDraw);
}
else if (savings.withdraw(withdraw1) == 0){
System.out.println("Invalid Input");
}

}
}
}
}

This study source was downloaded by 100000837799267 from CourseHero.com on 11-16-2022 00:39:01 GMT -06:00

https://www.coursehero.com/file/111634267/RunSavingsAccountjava/
Powered by TCPDF (www.tcpdf.org)

You might also like