DEV Community

Cover image for Simple if and else program using java
Kavitha
Kavitha

Posted on

Simple if and else program using java

ATM withdrawal:
Conditions:
1.Balance 5000$.
2.If Balance is below than 5000 , give this information like 'Withdrawal successfully'
3.If Balance is more than 5000 , give this information like 'Withdrawal Failed'

Program:

import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int withdrawl=sc.nextInt();
       int balance=5000;
       if(withdrawl<balance){
           System.out.println("Withdrawl Sucessfull");
       }
       else{
           System.out.println("Withdrawl Failed");
       }

    }
}


Enter fullscreen mode Exit fullscreen mode

Output:

49999
Withdrawl Failed

Enter fullscreen mode Exit fullscreen mode

Top comments (0)