Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine()),
- spent = 0;
- String command;
- while (true) {
- command = scanner.nextLine();
- double price = 0;
- if (budget == 0) {
- System.out.println("Out of money!");
- break;
- } else if (command.equals("Game Time")) {
- System.out.printf("Total spent: $%.2f. Remaining: $%.2f\n", spent, budget);
- break;
- } else {
- price = switch (command) {
- case "OutFall 4" -> 39.99;
- case "CS: OG" -> 15.99;
- case "Zplinter Zell" -> 19.99;
- case "Honored 2" -> 59.99;
- case "RoverWatch" -> 29.99;
- case "RoverWatch Origins Edition" -> 39.99;
- default -> 0;
- };
- if (price == 0) {
- System.out.println("Not Found");
- } else {
- if (budget >= price) {
- System.out.println("Bought " + command);
- budget -= price;
- spent += price;
- } else {
- System.out.println("Too Expensive");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement