Oop First LAboratory
Oop First LAboratory
Oop First LAboratory
import java.util.Scanner;
savings.setInterestRate(scan.nextDouble());
while(true){
System.out.print("Press D for another deposit or W to Withdraw: ");
char x = scan.next().toUpperCase().charAt(0);
switch(x){
case'D':
if (savings.getBalance()> 1000){
savings.addInterest();
}
break;
case 'W':
System.out.print("Enter withdraw amount: ");
savings.deposit(scan.nextDouble());
break;
default:
System.out.println("Error input");
}
System.out.print("your new balance is: ");
savings.showBalance(savings);
package runsavingsaccount;
public class SavingsAccount {
SavingsAccount(){
Balance = 0;
}
}
void deposit (double amount){
Balance = Balance + amount;
}
double withdraw(double amount){
if (Balance >= amount){
amount = Balance - amount;
}else {
System.out.println("Amount is Equal to 0");
}
return amount;
}
void addInterest(){
}
}