Advertisement
MelindaElezovic

McDonalds

Dec 2nd, 2015
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. //Melinda
  2. //12/1/15
  3.  
  4. import java.util.*;
  5. public class McDonalds
  6. {
  7.   public static void main (String[] args)
  8.   {
  9.     Scanner input = new Scanner (System.in);
  10.     System.out.println("Enter the bill amount");
  11.     int bill = input.nextInt();
  12.    
  13.     if (bill >= 100)
  14.      System.out.println("I cannot accept a 100 dollar bill. Sorry.");
  15.     else if (bill==0)
  16.       System.out.println("No change");
  17.     else {
  18.       int twenty = bill/20;
  19.       int billTemp = bill - (twenty *20);
  20.       int ten = bill/10;
  21.       billTemp = bill - (ten * 10);
  22.       int five = billTemp/5;
  23.       int ones = billTemp = (five*5);
  24.       System.out.println(bill + " can be made using ");
  25.      
  26.       if (twenty>0)
  27.         System.out.print(twenty + " twenties ");
  28.       if (ten>0)
  29.         System.out.print(ten + " tens ");
  30.       if (five>0)
  31.         System.out.print(five + " fives ");
  32.       if (ones>0)
  33.         System.out.print(ones + " ones ");
  34.      
  35.     }
  36.     }
  37.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement