Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TestTask7 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int nPoints = Integer.parseInt(scanner.nextLine());
  7.         String arenaName = scanner.nextLine();
  8.         String day = scanner.nextLine();
  9.         String conditionItems = scanner.nextLine();
  10.  
  11.         int maxItems = 5;
  12.         double maxItemsPrice = 0;
  13.  
  14.         switch (conditionItems) {
  15.             case "Legendary":
  16.                 maxItemsPrice = 21000;
  17.  
  18.                 break;
  19.             case "Normal":
  20.                 maxItemsPrice = 14000;
  21.  
  22.                 break;
  23.             case "Poor":
  24.                 maxItemsPrice = 7000;
  25.  
  26.                 break;
  27.         }
  28.         if (arenaName.equals("Nagrand")) {
  29.             if ("Monday".equals(day) || "Wednesday".equals(day)) {
  30.                 maxItemsPrice = 0.95 * maxItemsPrice;
  31.             }
  32.         } else if (arenaName.equals("Gurubashi")) {
  33.             if ("Tuesday".equals(day) || "Thursday".equals(day)) {
  34.                 maxItemsPrice = 0.90 * maxItemsPrice;
  35.             }
  36.         } else if (arenaName.equals("Dire Maul")) {
  37.             if ("Friday".equals(day) || "Saturday".equals(day)) {
  38.                 maxItemsPrice = 0.93 * maxItemsPrice;
  39.             }
  40.  
  41.         }
  42.         double pricePerItem = maxItemsPrice / maxItems;
  43.  
  44.         double pointsLeft = 0;
  45.         int itemBought = 0;
  46.         String type = "";
  47.         if (nPoints - pricePerItem < pricePerItem) {
  48.             itemBought = 1;
  49.             pointsLeft = nPoints - pricePerItem;
  50.             type = "Failure!";
  51.         } else if (nPoints - 2 * pricePerItem < pricePerItem) {
  52.             itemBought = 2;
  53.             pointsLeft = nPoints - 2 * pricePerItem;
  54.             type = "Failure!";
  55.         } else if (nPoints - 3 * pricePerItem < pricePerItem) {
  56.             itemBought = 3;
  57.             pointsLeft = nPoints - 3 * pricePerItem;
  58.             type = "Failure!";
  59.         } else if (nPoints - 4 * pricePerItem < pricePerItem) {
  60.             itemBought = 4;
  61.             pointsLeft = nPoints - 4 * pricePerItem;
  62.             type = "Failure!";
  63.         } else {
  64.             itemBought = 5;
  65.             pointsLeft = nPoints - 5 * pricePerItem;
  66.             type = "Success!";
  67.         }
  68.         System.out.println("Items bought: " + itemBought);
  69.         System.out.printf("Arena points left: %.0f%n", pointsLeft);
  70.         System.out.println(type);
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement