-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest2.java
More file actions
84 lines (73 loc) · 1.85 KB
/
test2.java
File metadata and controls
84 lines (73 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.util.*;
class Account {
public static int id = 0;;
private double balance = 500.0;
private static double annualInterestRate = 4.0;
public Account()
{
++id;
}
public Account(int id, double balance)
{
this.id = id;
this.balance = balance;
}
public double getMonthlyInterest()
{
return (balance*annualInterestRate)/1200;
}
public void withdraw(double amount)
{
this.balance=this.balance-amount;
System.out.println("current balance=Rs. "+this.balance);
}
public void deposit(double amount)
{
this.balance=this.balance+amount;
System.out.println("current balance=Rs. "+this.balance);
}
}
public class test2
{
public static void main(String[] args)
{
Scanner ob = new Scanner(System.in);
// System.out.println("enter test case");
// int t=ob.nextInt();
//System.out.println("enter id");
//int n=ob.nextInt();
int ch;
// while(t>0)
//{
do
{
System.out.println("1.MONTHLY INTEREST ");
System.out.println("2. WITHDRAW ");
System.out.println("3. DEPOSIT ");
System.out.println("ENTER CHOICE");
ch=ob.nextInt();
Account f=new Account();
Account e = new Account(f.id,500);
switch(ch)
{
case 1:
System.out.println("Monthly interest=Rs. "+e.getMonthlyInterest());
break;
case 2:
System.out.println("enter amount to withdraw");
double w=ob.nextDouble();
e.withdraw(w);
break;
case 3:
System.out.println("enter amount to deposit");
double d=ob.nextDouble();
e.deposit(d);
break;
default:
System.out.println("Wrong choice");
}
}while(ch<4);
//t--;
//}
}
}