Question

In: Computer Science

Create the logic for an application that instantiates an object of the ATM class. Prompt the...

Create the logic for an application that instantiates an object of the ATM class. Prompt the user for the ATM object data to display the user’s bank balance

PROGRAMMING LOGIC AND DESIGN QUESTION

JAVA LANGUAGE

Solutions

Expert Solution

`Hey,

Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.

import java.util.Scanner;
public class ATM_Transaction
{
public static void main(String args[] )
{
int balance = 5000, withdraw, deposit;
Scanner s = new Scanner(System.in);
while(true)
{
System.out.println("Automated Teller Machine");
System.out.println("Choose 1 for Withdraw");
System.out.println("Choose 2 for Deposit");
System.out.println("Choose 3 for Check Balance");
System.out.println("Choose 4 for EXIT");
System.out.print("Choose the operation you want to perform:");
int n = s.nextInt();
switch(n)
{
case 1:
System.out.print("Enter money to be withdrawn:");
withdraw = s.nextInt();
if(balance >= withdraw)
{
balance = balance - withdraw;
System.out.println("Please collect your money");
}
else
{
System.out.println("Insufficient Balance");
}
System.out.println("");
break;

case 2:
System.out.print("Enter money to be deposited:");
deposit = s.nextInt();
balance = balance + deposit;
System.out.println("Your Money has been successfully depsited");
System.out.println("");
break;

case 3:
System.out.println("Balance : "+balance);
System.out.println("");
break;

case 4:
System.exit(0);
}
}
}
}

Kindly revert for any queries

Thanks.


Related Solutions

// Creates a Breakfast class // and instantiates an object // Displays Breakfast special information using...
// Creates a Breakfast class // and instantiates an object // Displays Breakfast special information using System; using static System.Console; using System.Globalization; class DebugNine2 {    static void Main()    {       Breakfast special = new Breakfast("French toast", 4.99);       //Display the info about breakfast       WriteLine(special.INFO);       // then display today's special       WriteLine("Today we are having {0} for {1}",          special.Name, special.Price.ToString("C2", CultureInfo.GetCultureInfo("en-US")));   } } class Breakfast {    public string INFO =       "Breakfast is the most important meal of the day.";       // Breakfast constructor requires...
Create a C# Application. Create a class object called “Employee” which includes the following private variables:...
Create a C# Application. Create a class object called “Employee” which includes the following private variables: firstN lastN idNum wage: holds how much the person makes per hour weekHrsWkd: holds how many total hours the person worked each week regHrsAmt: initialize to a fixed amount of 40 using constructor. regPay otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods: constructor properties CalcPay(): Calculate the regular pay and overtime pay. Create...
Create an application named MaxRowSum.java that instantiates a 20x20 two-dimentional array of integers, populates it with...
Create an application named MaxRowSum.java that instantiates a 20x20 two-dimentional array of integers, populates it with random integers drawn from the range 1 to 100, and then output the index of the row with the highest sum along all the rows. To support your solution, create a class named RowSumThread.java from which you can instantiate Runnable objects, each of which will sum one row of the two-dimensional array and then place the sum of that row into the appropriate slot of a one-dimensional, 20-element array. To Summarize, your application will: 1. Generate the two-dimensional array of random integers 2. Start 20 concurrent threads, each of which places the sum of one row of the two-dimensional array into the corresponding slot of a one-dimensional array. 3. Onput the index of the row with the maximum value.
Create an application named MaxRowSum.java that instantiates a 20x20 two-dimentional array of integers, populates it with...
Create an application named MaxRowSum.java that instantiates a 20x20 two-dimentional array of integers, populates it with random integers drawn from the range 1 to 100, and then output the index of the row with the highest sum along all the rows. To support your solution, create a class named RowSumThread.java from which you can instantiate Runnable objects, each of which will sum one row of the two-dimensional array and then place the sum of that row into the appropriate slot...
Create a Java application that will prompt the user for the first name of 6 friends...
Create a Java application that will prompt the user for the first name of 6 friends in any order and store them in an array. First, output the array unsorted. Next, sort the array of friends and then output the sorted array to the screen. Be sure to clearly label the output. See the example program input and output shown below. It does not have to be exactly as shown in the example, however it gives you an idea of...
Create a class named GameCharacter to define an object as follows: The class should contain class...
Create a class named GameCharacter to define an object as follows: The class should contain class variables for charName (a string to store the character's name), charType (a string to store the character's type), charHealth (an int to store the character's health rating), and charScore (an int to store the character's current score). Provide a constructor with parameters for the name, type, health and score and include code to assign the received values to the four class variables. Provide a...
Create in java an interactive GUI application program that will prompt the user to use one...
Create in java an interactive GUI application program that will prompt the user to use one of three calculators, label project name MEDCALC. You can use any color you want for your background other than grey. Be sure to label main java box with “MEDCALC” and include text of “For use only by students” On all three calculators create an alert and signature area for each user. The alert should be something like “All calculations must be confirmed by user...
A Bookstore Application C++ Design the class Book. Each object of the class Book can hold...
A Bookstore Application C++ Design the class Book. Each object of the class Book can hold the following information about a book: title, authors, publisher, ISBN Include the member functions to perform the various operations on the objects of Book. For example, the typical operations that can be performed on the title are to show the title, set the title. Add similar operations for the publisher, ISBN , and authors. Add the appropriate constructors and a destructor (if one is...
C++ Question Create a class for a card in a deck of playing cards. The object...
C++ Question Create a class for a card in a deck of playing cards. The object must contain methods for setting and retrieving the suit and the type of card (type of card meaning 2,3,4,5,6,7,8,9,10,J,Q,K,A). Separate the declaration of the class from its implementation by using the declaration in a header file and the implementation in a .cpp file. Also create a driver program and a makefile which complies the code and makes it able to run. This is more...
Purpose: To write an Object-Oriented application that creates a Java class with several instance variables, a...
Purpose: To write an Object-Oriented application that creates a Java class with several instance variables, a constructor to initialize the instance variables, several methods to access and update the instance variables’ values, along with other methods to perform calculations. Also, write a test class that instantiates the first class and tests the class’s constructor and methods. Details: Create a class called Rectangle containing the following: Two instance variables, An instance variable of type double used to hold the rectangle’s width....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT