File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 4
4
//create ATMExample class to implement the ATM functionality
5
5
public class atm
6
6
{
7
+ public static boolean validateInputAmount (Integer amount )
8
+ {
9
+ return amount >0 ;
10
+ }
7
11
//main method starts
8
12
public static void main (String args [] )
9
13
{
@@ -30,7 +34,12 @@ public static void main(String args[] )
30
34
System .out .print ("Enter money to be withdrawn:" );
31
35
32
36
//get the withdrawl money from user
33
- withdraw = sc .nextInt ();
37
+ withdraw = sc .nextInt ();
38
+ if (!validateInputAmount (withdraw ))
39
+ {
40
+ System .out .println ("Enter amount greater than zero" );
41
+ break ;
42
+ }
34
43
35
44
//check whether the balance is greater than or equal to the withdrawal amount
36
45
if (balance >= withdraw )
@@ -53,6 +62,11 @@ public static void main(String args[] )
53
62
54
63
//get deposite amount from te user
55
64
deposit = sc .nextInt ();
65
+ if (!validateInputAmount (deposit ))
66
+ {
67
+ System .out .println ("Enter amount greater than zero" );
68
+ break ;
69
+ }
56
70
57
71
//add the deposit amount to the total balanace
58
72
balance = balance + deposit ;
You can’t perform that action at this time.
0 commit comments