Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Yahoo6
- {
- public static void main(String[] args)
- {
- Scanner sc = new Scanner(System.in);
- final int cost = 350;
- int balance = 0, t;
- while (cost > balance)
- {
- do
- {
- System.out.println("Your current Balance is: " + balance);
- System.out.println();
- System.out.print("Enter coin value (200, 100, 25, 10, 5):");
- t = sc.nextInt();
- if (t==5 || t == 10 || t == 25 || t == 100 || t == 200)
- balance += t;
- else
- System.out.println("Invalid Coin");
- } while(!(t == 200 || t ==100 || t ==25 || t ==10 || t == 5));
- }
- balance -= cost;
- System.out.printf("Paid: %d%nChange: %d", cost + balance, balance);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement