-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram5.java
More file actions
133 lines (128 loc) · 4.36 KB
/
Copy pathProgram5.java
File metadata and controls
133 lines (128 loc) · 4.36 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import java.util.*;
import java.lang.Math;
class Account {
String acc_name;
double acc_no;
int acc_type;
double balance;
void getdata(String name,double no,int type,double bal) {
acc_name=name;
acc_no=no;
acc_type=type;
balance=bal;
}
}
class Savings extends Account {
void deposit(double amt) {
balance=balance+amt;
System.out.println(balance);
}
void withdraw(double amt) {
balance=balance-amt;
System.out.println(balance);
}
void interest(int time, int no, double r) {
double a = 1 + r/no;
double b = no*time;
double c = Math.pow(a, b);
balance = balance * c;
System.out.println("The new balance is"+balance);
}
}
class Current extends Account {
void deposit(double amt) {
balance=balance+amt;
System.out.println(balance);
}
void withdraw(double amt) {
balance=balance-amt;
System.out.println(balance);
check(balance);
}
void check(double amt) {
if(amt<10000) {
balance =balance-500;
System.out.println("Insufficient Balance"+balance);
}
}
}
class Program5 {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int temp=1;
while(temp==1) {
double amt=0;
System.out.println("Enter name");
sc.next();
String name=sc.nextLine();
System.out.println("Enter acc_no");
double no=sc.nextDouble();
System.out.println("Enter acc_type\n1 for Savings\n2 for Current");
int type=sc.nextInt();
do {
System.out.println("Enter balance");
amt=sc.nextDouble();
} while(type==2 && amt<10000);
switch(type)
{
case 1:
{
Savings s=new Savings();
s.getdata(name,no,type,amt);
System.out.println("\n1.Deposit\n\2.Withdraw\n3.Interest");
int choice=sc.nextInt();
switch (choice){
case 1:{
System.out.println("Enter Amoumt");
double amt1=sc.nextDouble();
s.deposit(amt1);
break;
}
case 2:{
System.out.println("Enter Amoumt");
double amt1=sc.nextDouble();
s.withdraw(amt1);
break;
}
case 3:{
System.out.println("Enter time period");
int tp=sc.nextInt();
System.out.println("Enter Rate of Interest");
double r = sc.nextDouble();
double rate = r/100;
System.out.println("Enter no of times per time period");
int nof=sc.nextInt();
s.interest(tp, nof, rate);
break;
}
}
}
break;
case 2:
{
Current c=new Current();
c.getdata(name,no,type,amt);
System.out.println("\n1.Deposit\n\2.Withdraw");
int choice=sc.nextInt();
switch (choice){
case 1:{
System.out.println("Enter Amoumt");
double amt1=sc.nextDouble();
c.deposit(amt1);
break;
}
case 2:{
System.out.println("Enter Amoumt");
double amt1=sc.nextDouble();
c.withdraw(amt1);
break;
}
}
}
break;
}
System.out.println("To continue 1 else 0");
temp=sc.nextInt();
}
}
}