Advertisement
marking2112

GamingStore

Oct 1st, 2018
149
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 GamingStore {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double currentBalance = Double.parseDouble(scanner.nextLine());
  8.  
  9.         double remainingMoney = currentBalance;
  10.         double spent = 0;
  11.         while (true) {
  12.             String game = scanner.nextLine();
  13.             if (game.equals("Game Time")) {
  14.                 System.out.printf("Total spent: %.2f. Remaining: %.2f", spent, currentBalance - spent);
  15.                 break;
  16.  
  17.             }
  18.             if (game.equals("OutFall 4")) {
  19.                 if (remainingMoney < 39.99) {
  20.                     System.out.println("Too Expensice");
  21.  
  22.                 } else {
  23.                     remainingMoney -= 39.99;
  24.                     spent += 39.99;
  25.                     System.out.println("OutFall 4");
  26.                 }
  27.             } else if (game.equals("CS: OG")) {
  28.                 if (remainingMoney < 15.99) {
  29.                     System.out.println("Too Expensive");
  30.  
  31.                 } else {
  32.                     remainingMoney -= 15.99;
  33.                     spent += 15.99;
  34.                     System.out.println("CS: OG");
  35.                 }
  36.             } else if (game.equals("Zplinter Zell")) {
  37.                 if (remainingMoney < 19.99) {
  38.                     System.out.println("Too Expensive");
  39.  
  40.                 } else {
  41.                     remainingMoney -= 19.99;
  42.                     spent += 19.99;
  43.                     System.out.println("Zplinter Zell");
  44.                 }
  45.             } else if (game.equals("Honored 2")) {
  46.                 if (remainingMoney < 59.99) {
  47.                     System.out.println("Too Expensive");
  48.  
  49.                 } else {
  50.                     remainingMoney -= 59.99;
  51.                     spent += 59.99;
  52.                     System.out.println("Honored 2");
  53.                 }
  54.             } else if (game.equals("RoverWatch")) {
  55.                 if (remainingMoney < 29.99) {
  56.                     System.out.println("Too Expensive");
  57.  
  58.                 } else {
  59.                     remainingMoney -= 29.99;
  60.                     spent += 29.99;
  61.                     System.out.println("RoverWatch");
  62.                 }
  63.             } else if (game.equals("RoverWatch Origins Edition")) {
  64.                 if (remainingMoney < 39.99) {
  65.                     System.out.println("Too Expensive");
  66.  
  67.                 } else {
  68.                     remainingMoney -= 39.99;
  69.                     spent += 39.99;
  70.                     System.out.println("RoverWatch Origins Edition");
  71.                 }
  72.             } else {
  73.                 System.out.println("Not Found");
  74.  
  75.             }
  76.             if (remainingMoney <= 0) {
  77.                 System.out.println("Out of money!");
  78.                 return;
  79.             }
  80.  
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement