Class Name MonthBalance
import javax.swing.JOptionPane;
public class MonthBalance {
public static void main(String[] args) {
String choice="element";
String Menu="\nd-Deposit \nw-Withdrawal \ne-Exit";
String Choice="element";
double balance = 0,d=0;
double yearlyRate=0.025,w=0;
do{
choice=JOptionPane.showInputDialog(Menu+"\n Enter Choice:");
choice=choice.toLowerCase();
switch(choice.charAt(0) ){
case 'd':
JOptionPane.showMessageDialog(null,"Beginning of Month Balance:" + balance);
balance=Double.parseDouble(JOptionPane.showInputDialog("enter Deposit"));
JOptionPane.showMessageDialog(null,"Beginning of Month Balance:" + balance);
break;
case 'w':
JOptionPane.showMessageDialog(null,"Beginning of Month Balance:"+balance);
w=Double.parseDouble(JOptionPane.showInputDialog("Enter withdrawal amount:"));
balance = balance+(yearlyRate / 12) * balance;
JOptionPane.showMessageDialog(null,"Balance after transaction:"+ (balance=balance-w));
break;
case 'e': System.exit(0);
break;
default:JOptionPane.showMessageDialog(null,"Access Denied!");
}
}while(choice.charAt(0)!=('e'));
}
}
No comments:
Post a Comment