-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
48 lines (47 loc) · 994 Bytes
/
Transaction.java
File metadata and controls
48 lines (47 loc) · 994 Bytes
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
package amount ;
import java.io.*;
import java.lang.Exception;
class Exp extends Exception
{
Exp(String s)
{
super(s);
}
}
public class Transaction
{
public void transact()throws Exception
{
int pin,Amt,amount;
DataInputStream i=new DataInputStream(System.in);
int a=25000;
System.out.println("Hii Customer");
Thread.sleep(1000);
System.out.println("Enter your pin");
pin=Integer.parseInt(i.readLine());
Thread.sleep(1000);
System.out.println("Your current balance is 25000");
Thread.sleep(1000);
System.out.println("Please enter the amount to Debit");
amount=Integer.parseInt(i.readLine());
Amt=a-amount;
Thread.sleep(1000);
System.out.println("Your current balance is"+Amt);
Thread.sleep(1000);
try
{
if(amount<=25000 && amount>0)
{
System.out.println("Your transaction is valid");
}
else
{
throw new Exp("Sorry your transaction is invalid");
}
}
catch(Exp e)
{
System.out.println(e.getMessage());
}
}
}