In: Computer Science
First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).
Then create a new Java application called "AtmSimulator" (without the quotation marks) (not ATMSimluator!) that simulates a simple one-transaction ATM according to the following guidelines.
The program should start with an initial account balance, which you can set to any legitimate double value. All output of currency values should include a leading dollar sign and use two decimal positions. Prompt the user with the following prompt (without the dashed lines).
Enter the number of your desired transaction type.
/* Please change the class name to same as the file name of .java file and then compile and run it.
I am also attaching the output for the same. You can run it here also https://www.onlinegdb.com/online_java_compiler but of you are running here make sure to change classname to Main. All the functions and outputs are according to the specifications provided in the question. Thank You*/
import java.util.Scanner;
public class AtmSimulator
{
public static void main(String args[] )
{
double balance = 1000, withdraw, deposit;
Scanner s = new Scanner(System.in);
while(true)
{
System.out.println("Enter the number of your desired transaction
type");
System.out.println("Balance");
System.out.println("Deposit");
System.out.println("Withdrawl");
System.out.println("quit");
int n = s.nextInt();
switch(n)
{
case 1:
System.out.println("Your Current Balance is $"+balance);
break;
case 2:
System.out.print("Enter the amount of the deposit:");
deposit = s.nextDouble();
balance = balance + deposit;
System.out.println("Your current balance is $"+balance);
break;
case 3:
System.out.print("Enter the amount of the withdrawal:");
withdraw = s.nextDouble();
if(balance >= withdraw)
{
balance = balance - withdraw;
System.out.println("Your current balance is $"+balance);
}
else
{
System.out.println("Insufficient funds. Your current balance is
$"+balance);
}
System.out.println("");
break;
case 4:
System.out.println("Good-bye.");
System.exit(0);
break;
default:
System.out.println("Invalid menu choice.");
System.exit(0);
break;
}
}
}
}