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