Advertisement
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 scanner = new Scanner(System.in);
- double currentBalance = Double.parseDouble(scanner.nextLine());
- double remainingMoney = currentBalance;
- double spent = 0;
- while (true) {
- String game = scanner.nextLine();
- if (game.equals("Game Time")) {
- System.out.printf("Total spent: %.2f. Remaining: %.2f", spent, currentBalance - spent);
- break;
- }
- if (game.equals("OutFall 4")) {
- if (remainingMoney < 39.99) {
- System.out.println("Too Expensice");
- } else {
- remainingMoney -= 39.99;
- spent += 39.99;
- System.out.println("OutFall 4");
- }
- } else if (game.equals("CS: OG")) {
- if (remainingMoney < 15.99) {
- System.out.println("Too Expensive");
- } else {
- remainingMoney -= 15.99;
- spent += 15.99;
- System.out.println("CS: OG");
- }
- } else if (game.equals("Zplinter Zell")) {
- if (remainingMoney < 19.99) {
- System.out.println("Too Expensive");
- } else {
- remainingMoney -= 19.99;
- spent += 19.99;
- System.out.println("Zplinter Zell");
- }
- } else if (game.equals("Honored 2")) {
- if (remainingMoney < 59.99) {
- System.out.println("Too Expensive");
- } else {
- remainingMoney -= 59.99;
- spent += 59.99;
- System.out.println("Honored 2");
- }
- } else if (game.equals("RoverWatch")) {
- if (remainingMoney < 29.99) {
- System.out.println("Too Expensive");
- } else {
- remainingMoney -= 29.99;
- spent += 29.99;
- System.out.println("RoverWatch");
- }
- } else if (game.equals("RoverWatch Origins Edition")) {
- if (remainingMoney < 39.99) {
- System.out.println("Too Expensive");
- } else {
- remainingMoney -= 39.99;
- spent += 39.99;
- System.out.println("RoverWatch Origins Edition");
- }
- } else {
- System.out.println("Not Found");
- }
- if (remainingMoney <= 0) {
- System.out.println("Out of money!");
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement