Question

In: Computer Science

Java program that display ATM booth line by using data sturcture Queue.

Java program that display ATM booth line by using data sturcture Queue.

Solutions

Expert Solution

import java.util.*;

import java.util.Scanner;

public class Atm_Booth

{

public static void main(String args[])

{

int b=5000, wd, dep;

Scanner s= new Scanner(System.in);

while(true)

{

System.out.println(".....ATM....");

System.out.println("Choose 1 to withdraw");

System.out.println("Choose 2 to deposit");

System.out.println("Choose 3 to check balance");

System.out.println("Choose 4 to exit");

System.out.println("Choose the operation you want to perform");

int n=s.nextInt();

switch(n)

{

case 1:

System.out.print("Enter money to be withdrawn:");

wd = s.nextInt();

if(b>= wd)

{

b=b-wd;

System.out.println("Please collect money");

}

else

{

System.out.println(" Insufficient balance");

}

System.out.println(" ");

break;

case 2:

System.out.println("Enter money to deposit");

dep=s.nextInt();

b=b+dep;

System.out.println(" Money deposited:");

System.out.println(" ");

break;

case 3:

System.out.println("Balance :"+b);

System.out.println(" ");

break;

case 4:

System.exit(0);

}

}

}

}


Related Solutions

Write a java program that read a line of input as a sentence and display: ...
Write a java program that read a line of input as a sentence and display:  Only the uppercase letters in the sentence.  The sentence, with all lowercase vowels (i.e. “a”, “e”, “i”, “o”, and “u”) replaced by a strike symbol “*”.
write a java program to Implement a Priority Queue using a linked list. Include a main...
write a java program to Implement a Priority Queue using a linked list. Include a main method demonstrating enqueuing and dequeuing several numbers, printing the list contents for each.
Using a (GUI interface), write a Java program that simulates an ATM machine with the following...
Using a (GUI interface), write a Java program that simulates an ATM machine with the following options menu: "Welcome" 1. Deposit to account 2. Withdraw 3. Exit
Write a program in java that uses methods to input data for calculation, calculate, and display...
Write a program in java that uses methods to input data for calculation, calculate, and display the results of the calculations. That is, there are at least three methods. The problem is to write a program that calculates the area of a rectangle. This action should be repeatable.
Complete the following Java program to, using BigDecimal, calculate and display the radius of the circle...
Complete the following Java program to, using BigDecimal, calculate and display the radius of the circle whose diameter is stored in the variable diameter.  The radius is calculated as half of the diameter. For example, since diameter is 7.5, the program should calculate and display the radius like this:  (2 points)   (CLO 1) package q1; import java.math.BigDecimal; public class Q1 {     public static void main(String[] args) {         float diameter=7.5f;                        } }                                             Radius = 3.75 Consider the following Java program and...
Using the Queue ADT: Create a program that uses a Queue. Your program should ask the...
Using the Queue ADT: Create a program that uses a Queue. Your program should ask the user to input a few lines of text and then outputs strings in same order of entry. (use of the library ArrayDeque) In Java please.
Program in Java Write an algorithm to transfer the elements from queue Q1 to queue Q2,...
Program in Java Write an algorithm to transfer the elements from queue Q1 to queue Q2, so that the contents in Q2 will be in reverse order as they are in Q1 (e.g. if your queue Q1 has elements A, B, and C from front to rear, your queue Q2 should have C, B, and A from front to rear). Your algorithm must explicitly use an additional stack to solve the problem. Write your algorithm in pseudo code first, and...
In Java or C++, implement a stack and a queue using a linkedlist data structure.  You may...
In Java or C++, implement a stack and a queue using a linkedlist data structure.  You may not use any standard Java or C++ libraries. Assume your data structure only allows Strings. Implement the following operations for the data structure: Queue: enqueue, dequeue, create, isEmpty (10 points) Stack: push, pop, create, isEmpty (10 points) Here is a link to get started on transferring from Java to C++ http://www.horstmann.com/ccj2/ccjapp3.html (Links to an external site.) Upload a zip file with one implementation for...
Java Code using Queue Write a program that opens a text file and reads its contents...
Java Code using Queue Write a program that opens a text file and reads its contents into a queue of characters, it should read character by character (including space/line change) and enqueue characters into a queue one by one. Dequeue characters, change their cases (upper case to lower case, lower case to upper case) and save them into a new text file (all the chars are in the same order as the original file, but with different upper/lower case) use...
Using Eclipse IDE Create a Java Program/Class named MonthNames that will display the Month names using...
Using Eclipse IDE Create a Java Program/Class named MonthNames that will display the Month names using an array. 1. Create an array of string named MONTHS and assign it the values "January" through "December". All 12 months need to be in the array with the first element being "January", then "February", etc. 2. Using a loop, prompt me to enter an int variable of 1-12 to display the Month of the Year. Once you have the value, the program needs...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT