Question

In: Computer Science

First, launch NetBeans and close any previous projects that may be open (at the top menu...

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.

  1. Balance
  2. Deposit
  3. Withdrawal
  4. Quit
  • If a balance is requested, the program should output "Your current balance is $X.XX" where X.XX is the initial balance, and then stop.
  • If a deposit is requested, prompt the user to enter the amount of the deposit (use a double for this). Add the deposit amount to the initial balance and then print "Your current balance is $X.XX" where X.XX is the new balance after the deposit, and then stop.
  • If a withdrawal is requested, prompt the user to enter the amount of the withdrawal (use a double for this). If the proposed withdrawal amount is less than or equal to the initial balance, print “Your current balance is $X.XX” where X.XX is the new balance after the withdrawal, and then stop. If the proposed withdrawal amount exceeds the initial balance, print "Insufficient funds. Your current balance is $X.XX" where X.XX is the initial balance, and then stop.
  • If "Quit" is requested, the program should print "Good-bye." and then stop.
  • If a number other than 1, 2, 3, or 4 is received, output "Invalid menu choice." and then stop.

Solutions

Expert Solution

/* 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;
}
}
}
}


Related Solutions

First, launch NetBeans and close any previous projects that may be open (at the top menu...
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 "AverageWithMethods" (without the quotation marks) according to the following guidelines. The program prompts the user for five to ten numbers, all on one line, and separated by spaces. Then the user calculates the average of those numbers, and displays the numbers and their average to the user. The program uses...
In java, follow the methods in bold First, launch NetBeans and close any previous projects that...
In java, follow the methods in bold 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 "WeightedAvgDataAnalyzer" (without the quotation marks), that modifies the DataAnalyzer.java in Horstmann Section 7.5, pp. 350-351 according to the specifications below. The input file should be called 'data.txt' and should be created according to the highlighted instructions below. Note that even though you know...
What are the advantages of asking open-ended questions? Are there any advantages to asking close-ended questions?...
What are the advantages of asking open-ended questions? Are there any advantages to asking close-ended questions? What about disadvantages for each question type? Why would we use surveys to collect self-report or victimization data? What makes them the best choice for this type of data collection? Why should we be aware of bias in questionnaire items? What can we do to reduce bias in our questions?
i need a javafx code 1. first create menu bar with option open and save 2....
i need a javafx code 1. first create menu bar with option open and save 2. when user click on open it opens the file only image file 3. when user click on save it saves as new file.
Ms. Jenny Joy is planning to open her first own business project: a little café close...
Ms. Jenny Joy is planning to open her first own business project: a little café close to the university district of the imaginary town of Brightside. She has rented a small, but nice venue for the café. She has worked hard to keep the target opening date of 1 June. There is a very important report missing from her paperwork though; she does not know how much profit she can expect during the first 3 months of operation. She remembers...
Ms. Jenny Joy is planning to open her first own business project: a little café close...
Ms. Jenny Joy is planning to open her first own business project: a little café close to the university district of the imaginary town of Brightside. She has rented a small, but nice venue for the café. She has worked hard to keep the target opening date of 1 June. There is a very important report missing from her paperwork though; she does not know how much profit she can expect during the first 3 months of operation. She remembers...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT