la-ma-rin

gamingStore

Jan 28th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class gamingStore {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         double budget = Double.parseDouble(scan.nextLine());
  8.  
  9.         String game = scan.nextLine();
  10.  
  11.         double total = budget;
  12.  
  13.         while (!"Game Time".equals(game)) {
  14.  
  15.             switch (game) {
  16.                 case "OutFall 4":
  17.                     if (total >= 39.99) {
  18.                         total -= 39.99;
  19.                         System.out.println("Bought " + game);
  20.                     } else {
  21.                         System.out.println("Too Expensive");
  22.                     }
  23.                     break;
  24.                 case "CS: OG":
  25.                     if (total >= 15.99) {
  26.                         total -= 15.99;
  27.                         System.out.println("Bought " + game);
  28.                     } else {
  29.                         System.out.println("Too Expensive");
  30.                     }
  31.                     break;
  32.                 case "Zplinter Zell":
  33.                     if (total >= 19.99) {
  34.                         total -= 19.99;
  35.                         System.out.println("Bought " + game);
  36.                     } else {
  37.                         System.out.println("Too Expensive");
  38.                     }
  39.                     break;
  40.                 case "Honored 2":
  41.                     if (total >= 59.99) {
  42.                         total -= 59.99;
  43.                         System.out.println("Bought " + game);
  44.                     } else {
  45.                         System.out.println("Too Expensive");
  46.                     }
  47.                     break;
  48.                 case "RoverWatch":
  49.                     if (total >= 29.99) {
  50.                         total -= 29.99;
  51.                         System.out.println("Bought " + game);
  52.                     } else {
  53.                         System.out.println("Too Expensive");
  54.                     }
  55.                     break;
  56.                 case "RoverWatch Origins Edition":
  57.                     if (total >= 39.99) {
  58.                         total -= 39.99;
  59.                         System.out.println("Bought " + game);
  60.                     } else {
  61.                         System.out.println("Too Expensive");
  62.                     }
  63.                     break;
  64.                 default:
  65.                     System.out.println("Not Found");
  66.                     break;
  67.             }
  68.             game = scan.nextLine();
  69.         }
  70.  
  71.         if (total == 0) {
  72.             System.out.println("Out of mo-ney");
  73.         } else {
  74.             System.out.printf("Total spent: $%.2f. Remaining: $%.2f", budget - total, total);
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment