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

Assignment First, launch NetBeans and close any previous projects that may be op

ID: 3593206 • Letter: A

Question

Assignment

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 "AtmSimDoLoop" (without the quotation marks) that simulates a simple 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) using a do loop.

Enter the number of your desired transaction type.

Balance

Deposit

Withdrawal

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 re-display the prompt and await the next transaction type.

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 re-display the prompt and await the next transaction type.

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 re-display the prompt and await the next transaction type. 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 re-display the prompt and await the next transaction type.

If "Quit" is requested, the program should print "Good-bye" and then stop.

thank you

Explanation / Answer

ATMMachine.java

import java.text.NumberFormat;
import java.util.Scanner;

public class ATMMachine {

public static void main(String[] args) {
//declaring variables
double account_balance = 50000, deposit_amount, withdraw_amount;
int choice;
NumberFormat fmt = NumberFormat.getCurrencyInstance();

//scanner object is used to read the inputs entered by the user.
Scanner sc = new Scanner(System.in);

//This do...while loop continue to execute until user enters choice as '4'
do {
//Displaying the menu
System.out.println(" Enter the number of your desired transaction type.");
System.out.println("1. Balance");
System.out.println("2. Deposit");
System.out.println("3. Withdrawal");
System.out.println("4. Quit");

//getting the choice entered by the user
System.out.print("Choice :");
choice = sc.nextInt();

/* Based on the user entered choice the corresponding
* operation will be performed
*/
switch (choice) {
case 1:
{
//Displaying the current account balance
System.out.println("Your Current Balance is :" + fmt.format(account_balance));
break;
}
case 2:
{

//Getting the Deposit amount entered by the user.
System.out.print("Enter Deposit Amount :$");
deposit_amount = sc.nextDouble();

//Adding the deposit amount to the current balance amount.
account_balance = account_balance + deposit_amount;

//Displaying the current account balance after amount deposited
System.out.println("Your current balance is :" + fmt.format(account_balance));
break;
}
case 3:
{
//Getting the with drawl amount from the user
System.out.print("Enter Withdraw Amount :$");
withdraw_amount = sc.nextDouble();

/* Checking the withdrawl amount is greater than account balance or not
* If greater,then Display the Error Message to the user.
*/
if (withdraw_amount > account_balance) {
System.out.println(":: Insufficient funds ::");

//Displaying the current account balance.
System.out.println("Your current balance is :" + fmt.format(account_balance));
continue;
}
//Subtracting with drawl amount from the account balance
account_balance = account_balance - withdraw_amount;

//Displaying the current account balance after withdrawl operation.
System.out.println("Your current balance is :$" + fmt.format(account_balance));
break;
}
case 4:
{
//Displaying the message
System.out.println("Good-bye.");
break;
}

}
} while (choice != 4);

}

}

_______________________

Output:


Enter the number of your desired transaction type.
1. Balance
2. Deposit
3. Withdrawal
4. Quit
Choice :1
Your Current Balance is :$50,000.00

Enter the number of your desired transaction type.
1. Balance
2. Deposit
3. Withdrawal
4. Quit
Choice :2
Enter Deposit Amount :$20000
Your current balance is :$70,000.00

Enter the number of your desired transaction type.
1. Balance
2. Deposit
3. Withdrawal
4. Quit
Choice :3
Enter Withdraw Amount :$30000
Your current balance is :$$40,000.00

Enter the number of your desired transaction type.
1. Balance
2. Deposit
3. Withdrawal
4. Quit
Choice :4
Good-bye.

_____________Could you rate me well.Plz .Thank You

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