-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest.java
More file actions
68 lines (61 loc) · 1.63 KB
/
Test.java
File metadata and controls
68 lines (61 loc) · 1.63 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
import java.util.*;
class Account {
private int id = 0;
private double balance = 500.0;
private static double annualInterestRate = 4.0;
public Account()
{
}
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 Test
{
public static void main(String[] args)
{
Scanner ob = new Scanner(System.in);
System.out.println("enter id");
int n=ob.nextInt();
Account e = new Account(n,500);
System.out.println("1.MONTHLY INTEREST ");
System.out.println("2. WITHDRAW ");
System.out.println("3. DEPOSIT ");
System.out.println("ENTER CHOICE");
int ch=ob.nextInt();
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");
}
}
}