Advertisement
Guest User

Untitled

a guest
Apr 1st, 2019
716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class kur {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scan = new Scanner(System.in);
  7.  
  8.         String input = scan.nextLine();
  9.  
  10.         double balance = Double.parseDouble(input);
  11.         double totalmoney = balance;
  12.         double totalSpend = 0;
  13.         double price;
  14.  
  15.         while (!"Game time".equalsIgnoreCase(input = scan.nextLine())) {
  16.            
  17.             price = 0;
  18.             if (balance == 0) {
  19.                 System.out.println("Out of money!");
  20.                 break;
  21.             }
  22.             switch (input) {
  23.                 case "OutFall 4":
  24.                     price = 39.99;
  25.                     break;
  26.                 case "CS: OG":
  27.                     price = 15.99;
  28.                     break;
  29.                 case "Zplinter Zell":
  30.                     price = 19.99;
  31.                     break;
  32.                 case "Honored 2":
  33.                     price = 59.99;
  34.                     break;
  35.                 case "RoverWatch":
  36.                     price = 29.99;
  37.                     break;
  38.                 case "RoverWatch Origins Edition":
  39.                     price = 39.99;
  40.                     break;
  41.                 default:
  42.                     System.out.println("Not Found");
  43.                     break;
  44.             }
  45.             if (balance >= price && price > 0) {
  46.  
  47.                 totalSpend += price;
  48.                 balance -= price;
  49.                 System.out.printf("Bought %s%n", input);
  50.  
  51.             }else if (balance < price && price > 0) {
  52.  
  53.                 System.out.println("Too Expensive");
  54.             }
  55.         }
  56.         if (balance > 0) {
  57.             System.out.printf("Total spent: $%.2f. Remaining: $%.2f", totalSpend, (totalmoney - totalSpend));
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement