Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TestTask7 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int nPoints = Integer.parseInt(scanner.nextLine());
- String arenaName = scanner.nextLine();
- String day = scanner.nextLine();
- String conditionItems = scanner.nextLine();
- int maxItems = 5;
- double maxItemsPrice = 0;
- switch (conditionItems) {
- case "Legendary":
- maxItemsPrice = 21000;
- break;
- case "Normal":
- maxItemsPrice = 14000;
- break;
- case "Poor":
- maxItemsPrice = 7000;
- break;
- }
- if (arenaName.equals("Nagrand")) {
- if ("Monday".equals(day) || "Wednesday".equals(day)) {
- maxItemsPrice = 0.95 * maxItemsPrice;
- }
- } else if (arenaName.equals("Gurubashi")) {
- if ("Tuesday".equals(day) || "Thursday".equals(day)) {
- maxItemsPrice = 0.90 * maxItemsPrice;
- }
- } else if (arenaName.equals("Dire Maul")) {
- if ("Friday".equals(day) || "Saturday".equals(day)) {
- maxItemsPrice = 0.93 * maxItemsPrice;
- }
- }
- double pricePerItem = maxItemsPrice / maxItems;
- double pointsLeft = 0;
- int itemBought = 0;
- String type = "";
- if (nPoints - pricePerItem < pricePerItem) {
- itemBought = 1;
- pointsLeft = nPoints - pricePerItem;
- type = "Failure!";
- } else if (nPoints - 2 * pricePerItem < pricePerItem) {
- itemBought = 2;
- pointsLeft = nPoints - 2 * pricePerItem;
- type = "Failure!";
- } else if (nPoints - 3 * pricePerItem < pricePerItem) {
- itemBought = 3;
- pointsLeft = nPoints - 3 * pricePerItem;
- type = "Failure!";
- } else if (nPoints - 4 * pricePerItem < pricePerItem) {
- itemBought = 4;
- pointsLeft = nPoints - 4 * pricePerItem;
- type = "Failure!";
- } else {
- itemBought = 5;
- pointsLeft = nPoints - 5 * pricePerItem;
- type = "Success!";
- }
- System.out.println("Items bought: " + itemBought);
- System.out.printf("Arena points left: %.0f%n", pointsLeft);
- System.out.println(type);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement