Computer Science, asked by nanditasome3, 20 days ago

help me pls fast
Write a program in java to enter the user input in an ATM

machine and display the message on the screen based on the

user’s choice using a switch case statement

Press 1  To enquire about the Balance

Press 2  To withdraw balance

Press 3  To deposit balance

Press 0  To exit transaction menu​

Answers

Answered by devindernegi211
0

Explanation:

help me pls fast

Write a program in java to enter the user input in an ATM

machine and display the message on the screen based on the

user’s choice using a switch case statement

Press 1  To enquire about the Balance

Press 2  To withdraw balance

Press 3  To deposit balance

Press 0  To exit transaction menu

Answered by cuteprincess12364
1

Answer:

import java.util.Scanner;

public class ATM

{

public static void main(String args[] )

{

int balance = 5000, withdraw, deposit;

Scanner s = new Scanner(System.in);

while(true)

{

System.out.println("Automated Teller Machine");

System.out.println("Choose 1 for Withdraw");

System.out.println("Choose 2 for Deposit");

System.out.println("Choose 3 for Check Balance");

System.out.println("Choose 4 for EXIT");

System.out.print("Choose the operation you want to perform:");

int n = s.nextInt();

switch(n)

{

case 1:

System.out.print("Enter money to be withdrawn:");

withdraw = s.nextInt();

if(balance >= withdraw)

{

balance = balance - withdraw;

System.out.println("Please collect your money");

}

else

{

System.out.println("Insufficient Balance");

}

System.out.println("");

break;

case 2:

System.out.print("Enter money to be deposited:");

deposit = s.nextInt();

balance = balance + deposit;

System.out.println("Your Money has been successfully depsited");

System.out.println("");

break;

case 3:

System.out.println("Balance : "+balance);

System.out.println("");

break;

case 4:

System.exit(0);

}

}

}

}

please mark me as brainliest

Similar questions