YavorGrancharov

VaporStore

Jun 4th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.00 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class VaporStore {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.  
  7.         double balance = Double.parseDouble(console.nextLine());
  8.  
  9.         double price = 0.00;
  10.  
  11.         double totalPrice = 0.00;
  12.  
  13.         String[] game = new String[6];
  14.         game[0] = "OutFall 4";
  15.         game[1] = "CS: OG";
  16.         game[2] = "Zplinter Zell";
  17.         game[3] = "Honored 2";
  18.         game[4] = "RoverWatch";
  19.         game[5] = "RoverWatch Origins Edition";
  20.  
  21.         for (int i = 0; ; i++) {
  22.             String boutGame = console.nextLine();
  23.             if (!boutGame.equals("Game Time")) {
  24.                 if (boutGame.equals(game[0])) {
  25.                     price = 39.99;
  26.                 } else if (boutGame.equals(game[1])) {
  27.                     price = 15.99;
  28.                 } else if (boutGame.equals(game[2])) {
  29.                     price = 19.99;
  30.                 } else if (boutGame.equals(game[3])) {
  31.                     price = 59.99;
  32.                 } else if (boutGame.equals(game[4])) {
  33.                     price = 29.99;
  34.                 } else if (boutGame.equals(game[5])) {
  35.                     price = 39.99;
  36.                 }
  37.                 else
  38.                 {
  39.                     System.out.println("Not Found");
  40.                     continue;
  41.                 }
  42.  
  43.                 if (balance < price) {
  44.                     System.out.println("Too Expensive");
  45.                     continue;
  46.                 } else {
  47.                     balance -= price;
  48.                     System.out.println("Bought " + boutGame);
  49.                     totalPrice += price;
  50.                 }
  51.  
  52.                 if (balance == 0) {
  53.                     System.out.println("Out of money!");
  54.                     break;
  55.                 }
  56.             }
  57.  
  58.             else {
  59.                 System.out.printf("Total spent: $%.2f%s%.2f", totalPrice,". Remaining: $", balance);
  60.                 break;
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment