Advertisement
drago68

3. Gaming Store

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