Question

I need to write a java program call atm machine. Simulate An Atm Machine. create 10...

I need to write a java program call atm machine. Simulate An Atm Machine. create 10 accounts in an array with id,…,9 and an initial balance of $100. The Systems Prompts the user to enter an id. If the id is entered incorrectly it will ask the user to enter a correct id. Once an id is accepted, the main menu is displayed as shown in the sample run. You can choice 1 for viewing the current balance, 2 for withdrawing money 3 for depositing money, and 4 for exiting the main menu. Once you exit the system it will prompt for an id again. Once the systems starts, it will not stop.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

import java.util.*;
class atm{
   public static void main(String args[]){
       Scanner s=new Scanner(System.in);
       int a[]=new int[10],j;
       for(j=0;j<10;j++){
           a[j]=100;
       }
       while(true){
           int id;
           while(true){
               System.out.print("Enter account id:");
               id=s.nextInt();
               if(id>=0 && id<=9){
                   break;
               }
               else{
                   System.out.println("incorrect,try again");
               }
           }
           while(true){
               System.out.println(" MAIN MENU");
               System.out.println("1.Current Balance");
               System.out.println("2.Withdraw Money");
               System.out.println("3.Deposit Money");
               System.out.println("4.Exit");
               int i;
               System.out.print("Enter Choice:");
               i=s.nextInt();
               if(i==1){
                   System.out.println("Current Balance is "+a[i]);
               }
               else if(i==2){
                   int b;
                   System.out.print("Enter amount to withdraw:");
                   b=s.nextInt();
                   if(b>a[id]){
                       System.out.println("Insufficient balance");
                   }
                   else{
                       a[id]=a[id]-b;
                       System.out.println("Successful");
                   }
               }
               else if(i==3){
                   int b;
                   System.out.print("Enter amount to deposit:");
                   b=s.nextInt();
                   a[id]=a[id]+b;
                   System.out.println("Successful");
               }
               else{
                   System.out.println("Thanks for using ATM");
                   break;
               }

           }          
       }
   }


}

Output:

Add a comment
Know the answer?
Add Answer to:
I need to write a java program call atm machine. Simulate An Atm Machine. create 10...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • this is for java programming Please use comments Use the Account class created in homework 8_2...

    this is for java programming Please use comments Use the Account class created in homework 8_2 to simulate an ATM machine. Create ten checking accounts in an array with id 0, 1, …, 9, initial balance of $100, and annualInterestRate of 0. The system prompts the user to enter an id between 0 and 9, or 999 to exit the program. If the id is invalid (not an integer between 0 and 9), ask the user to enter a valid...

  • Please i need the .H, .cpp and main.cpp files. Please use vector. its for my midterm so correct code that can run only....

    Please i need the .H, .cpp and main.cpp files. Please use vector. its for my midterm so correct code that can run only. Thank you. Pointers and Dynamic Memory – Chapter 11 1. Write code using pointers and the Accounts class from week 1 assignment as follows – create a program in which you a. Create 10 accounts using an array with id’s 0 to 9 and refer to each account using pointer notation b. Add an initial balance of...

  • answer in c++ code. use comments when writing the code to know what's your thinking. there is three pictures with information Write a C++ console program that defines and utilizes a cl...

    answer in c++ code. use comments when writing the code to know what's your thinking. there is three pictures with information Write a C++ console program that defines and utilizes a class named ATM. This program will demonstrate a composition relationship among classes because an ATM can contain many Accounts. You will need to reuse/modify the Account class you created in Assignment 10. The default constructor for the ATM class should initialize a private vector of 10 accounts, each with...

  • Write a program called problem4.cpp to implement an automatic teller machine (ATM) following the BankAccount class...

    Write a program called problem4.cpp to implement an automatic teller machine (ATM) following the BankAccount class the we implemented in class. Your main program should initialize a list of accounts with the following values and store them in an array Account 101 → balance = 100, interest = 10% Account 201 → balance = 50, interest = 20% Account 108 → balance = 200, interest = 11% Account 302 → balance = 10, interest = 5% Account 204 → balance...

  • 1. Create a new multi-class Java program which implements a vending machine simulator which contains the...

    1. Create a new multi-class Java program which implements a vending machine simulator which contains the following functionality: A) At program startup, the vending machine is loaded with a variety of products in a variety of packaging for example soda/tonic/Coke in bottles, peanuts in bags, juice in cartons, etc. Also included is the cost of each item. The program should be designed to easily load a different set of products easily (for example, from a file). Also at program startup,...

  • Create a class named UserAccounts that defines an array of 8 accounts as an instance variable....

    Create a class named UserAccounts that defines an array of 8 accounts as an instance variable. In the default constructor of this class, write a loop that creates 8 accounts with ids 1 through 7 and initial balance of $50 for each account. Store these accounts in the array. When the program runs, it asks the use to enter a specific id. When the user enters a correct id, the system displays a menu as shown in the sample run...

  • java programe Write a program that prompts the user to enter in an integer number representing...

    java programe Write a program that prompts the user to enter in an integer number representing the number of elements in an integer array. Create the array and prompt the user to enter in values for each element using a for loop. When the array is full, display the following: The values in the array on a single line. The array with all of the elements reversed. The values from the array that have even numbered values. The values from...

  • Use your Car class from the previous Programming Assignment. For this assignment, create a new class...

    Use your Car class from the previous Programming Assignment. For this assignment, create a new class that represents a Used Car Dealership. Your Java program will simulate an inventory system for the dealership, where the employees can manage the car information. Start by creating an array of 10 cars, with an "ID" of 0 through 9, and use the default constructor to create each car. For example, the third car in an array called cars would have ID 2. You...

  • Hi I need help with a java program that I need to create a Airline Reservation...

    Hi I need help with a java program that I need to create a Airline Reservation System I already finish it but it doesnt work can someone please help me I would be delighted it doesnt show the available seats when running the program and I need it to run until someone says no for booking a seat and if they want to cancel a seat it should ask the user to cancel a seat or continue booking also it...

  • use java to design the application, the GUI should appear as in the picture shown ....

    use java to design the application, the GUI should appear as in the picture shown . Use java language: Requirements Document A local bank intends to install a new automated teller machine (ATM) to allow users (i.e., bank customers) to perform basic financial transactions. Each user can have only one account at the bank. ATM users should be able to view their account balance, withdraw cash (i.e., take money out of an account) and deposit funds (i.e., place money into...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT