SHARE
TWEET

GamingStore

shniaga Jan 28th, 2019 118 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package BasicSyntaxMoreExercise;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class GamingStore {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         double spent = 0;
  10.         double balance = Double.parseDouble(scanner.nextLine());
  11.  
  12.         while (true) {
  13.  
  14.             String gameName = scanner.nextLine();
  15.             if (gameName.equals("Game Time")) {
  16.                 System.out.println(String.format("Total spent: $%.2f. Remaining: $%.2f", spent, balance));
  17.                 break;
  18.             }
  19.             if (balance == 0) {
  20.                 System.out.println("Out of money!");
  21.                 break;
  22.             }
  23.             if (gameName.equals("OutFall 4") && balance >= 39.99) {
  24.                 balance -= 39.99;
  25.                 spent += 39.99;
  26.                 System.out.println("Bought OutFall 4");
  27.             } else if (gameName.equals("OutFall 4") && balance < 39.99) {
  28.                 System.out.println("Too Expensive");
  29.             } else if (gameName.equals("CS: OG") && balance >= 15.99) {
  30.                 balance -= 15.99;
  31.                 spent += 15.99;
  32.                 System.out.println("Bought CS: OG");
  33.             } else if (gameName.equals("OutFall 4") && balance < 15.99) {
  34.                 System.out.println("Too Expensive");
  35.             } else if (gameName.equals("Zplinter Zell") && balance >= 19.99) {
  36.                 balance -= 19.99;
  37.                 spent += 19.99;
  38.                 System.out.println("Bought Zplinter Zell");
  39.             } else if (gameName.equals("Zplinter Zell") && balance < 19.99) {
  40.                 System.out.println("Too Expensive");
  41.             } else if (gameName.equals("Honored 2") && balance >= 59.99) {
  42.                 balance -= 59.99;
  43.                 spent += 59.99;
  44.                 System.out.println("Bought Honored 2");
  45.             } else if (gameName.equals("Honored 2") && balance < 59.99) {
  46.                 System.out.println("Too Expensive");
  47.             } else if (gameName.equals("RoverWatch Origins Edition") && balance >= 39.99) {
  48.                 balance -= 39.99;
  49.                 spent += 39.99;
  50.                 System.out.println("Bought RoverWatch Origins Edition");
  51.             } else if (gameName.equals("RoverWatch Origins Edition") && balance < 39.99) {
  52.                 System.out.println("Too Expensive");
  53.             } else if (gameName.equals("RoverWatch") && balance >= 29.99) {
  54.                 balance -= 29.99;
  55.                 spent += 29.99;
  56.                 System.out.println("Bought RoverWatch");
  57.             } else if (gameName.equals("RoverWatch") && balance < 29.99) {
  58.                 System.out.println("Too Expensive");
  59.             } else {
  60.                 System.out.println("Not Found");
  61.             }
  62.  
  63.  
  64.         }
  65.  
  66.  
  67.     }
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top