Advertisement
Guest User

Untitled

a guest
May 29th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Yahoo6
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         Scanner sc = new Scanner(System.in);
  8.         final int cost = 350;
  9.         int balance = 0, t;
  10.  
  11.         while (cost > balance)
  12.         {
  13.             do
  14.             {
  15.                 System.out.println("Your current Balance is: " + balance);
  16.                 System.out.println();
  17.                
  18.                 System.out.print("Enter coin value (200, 100, 25, 10, 5):");
  19.                 t = sc.nextInt();
  20.  
  21.                 if (t==5 || t == 10 || t == 25 || t == 100 || t == 200)
  22.                     balance += t;
  23.                 else
  24.                     System.out.println("Invalid Coin");
  25.                
  26.             } while(!(t == 200 || t ==100 || t ==25 || t ==10 || t == 5));
  27.         }
  28.         balance -= cost;
  29.         System.out.printf("Paid: %d%nChange: %d", cost + balance, balance);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement