Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class atm {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int hundred = 0, fifty = 0, twenty = 0, tens = 0, fives = 0, ones = 0;
- System.out.println("Please Enter the amount you want to withdraw.");
- int withdraw = scan.nextInt();
- while (withdraw != 0) {
- if (withdraw / 100 > 0) {
- hundred = (withdraw / 100);
- withdraw = withdraw % 100;
- System.out.println("Hello world");
- if (withdraw / 50 > 0) {
- fifty = (int)(withdraw / 50);
- withdraw = withdraw % 50;
- System.out.println("hello3");
- if (withdraw / 20 > 0) {
- twenty = (int)(withdraw / 20);
- withdraw = withdraw % 20;
- System.out.println("hello4");
- if (withdraw / 10 > 0) {
- tens = (int)(withdraw / 10);
- withdraw = withdraw % 10;
- System.out.println("hello5");
- if (withdraw / 5 > 0) {
- fives = (int)(withdraw / 5);
- withdraw = withdraw % 5;
- if (withdraw > 0) {
- ones = (int)(withdraw / 1);
- withdraw = withdraw % 1;
- }
- }
- }
- }
- }
- }
- }
- System.out.println("You have recieved " + hundred + " hundreds\n "
- + fifty + " fiftys\n "
- + twenty + " twenties\n "
- + tens + " tens\n "
- + fives + " fives\n "
- + ones + " ones\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement