Advertisement
MoPhreak

Untitled

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