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