Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are to design a Java program to emulate the operations at an ATM. Use a rand

ID: 3639147 • Letter: Y

Question

You are to design a Java program to emulate the operations at an ATM. Use a random number generator to determine the arrival of a client and closure of the ATM.

For simplicity, use a random number generator to give the client his initial account balance after he arrives. A transaction menu is printed to allowed the client to choose from deposit, withdrawal, and balance inquiry. After each transaction, a receipt is printed, showing the balances before and after and type and amount of transaction. The client may order as many transactions as he wants until he decides to quit. Then the ATM is ready for the next client.

Error-checking for all kinds of input mistakes such as transaction choice, amount of transaction and insufficient fund for withdrawal is required.

Explanation / Answer

please rate - thanks

message me if any question

import java.util.*;
public class atm
{
public static void PrintMenu2()
    {System.out.println("*************** Menu ***************");
    System.out.println("1- Deposit an amount of money");
    System.out.println("2- Withdraw an amount of money");
    System.out.println("3- Display all information with new balance");
    System.out.println("4- Exit ");
    }
public static void receipt(double init,double end,double amt,int type)
{System.out.println("--------------------------");
System.out.print("Transaction summary Type: ");
if(type==1)
    System.out.println("Deposit");
else
    {System.out.println("Withdrawal");
    amt-=1;
    }
System.out.println("Initial Balance: $"+init);
System.out.println("Transaction amount: $"+amt);
System.out.println("Final Balance: $"+end);
System.out.println("--------------------------");
}  
public static void main(String[] args)
{int choice,selection,c=0;
double balance, amount,init;
Scanner in=new Scanner(System.in);
Random r=new Random();
do
{
selection=r.nextInt(1000);
c++;
if(selection>100&&selection<200)
{System.out.println("Wait time for new client was "+c+" random numbers");
balance=r.nextInt(100000)/100.;
System.out.println("New Client Opening balance: $"+balance);
do{
    PrintMenu2();   
    choice=in.nextInt();
    init=balance;
    switch(choice)
       {
        case 2:System.out.print("Enter amount: $");
                amount=in.nextDouble();
                if(amount>balance)
                     System.out.println("You do not have enough money to make that withdrawal");
                else
                     balance-=amount;
                    receipt(init,balance,amount,choice);
                break;
        case 1:System.out.print("Enter amount: $");
                amount=in.nextDouble();
                balance+=amount;
                    receipt(init,balance,amount,choice);
                break;           
         case 3:System.out.println("Current Balance: $"+balance);
                 break;
          case 4:System.out.println("Thanks for using our ATM! ");
                    c=0;
                 break;              
          default:System.out.println(choice+" Illegal entry ");
          }
}while (choice!=4);
}
}while(selection!=555);
System.out.println("ATM CLOSED--sorry for the inconvenience");
}
}
                   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote