package labExer3;
import java.util.Scanner;
public class RunSavingsAccount {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
SavingsAccount savings = new SavingsAccount();
System.out.print("Enter interest rate: ");
double rate = input.nextDouble();
SavingsAccount.setInterestRate(rate);
System.out.print("Enter amount to deposit: ");
double amount = input.nextDouble();
savings.deposit(amount);
SavingsAccount.showBalance(savings);
System.out.print("Press D for another deposit or W for withdrawal: ");
char choice = input.next().charAt(0);
if (choice == 'D' || choice == 'd') {
System.out.print("Enter amount to deposit: ");
amount = input.nextDouble();
savings.deposit(amount);
} else if (choice == 'W' || choice == 'w') {
System.out.print("Enter amount to withdraw: ");
amount = input.nextDouble();
savings.withdraw(amount);
}
SavingsAccount.showBalance(savings);
if (savings.getBalance() > 1000) {
savings.addInterest();
System.out.println("Interest added.");
SavingsAccount.showBalance(savings);
}
input.close();
}
}4 views