Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine()),
- price;
- int volume = Integer.parseInt(scanner.nextLine());
- String name;
- for (int i = 0; i < volume; i++) {
- name = scanner.nextLine();
- price = Double.parseDouble(scanner.nextLine());
- price *= switch (name) {
- case "Thrones" -> 0.5;
- case "Lucifer" -> 0.6;
- case "Protector" -> 0.7;
- case "TotalDrama" -> 0.8;
- case "Area" -> 0.9;
- default -> 1;
- };
- budget -= price;
- }
- if (budget >= 0) {
- System.out.printf("You bought all the series and left with %.2f lv.\n", budget);
- } else {
- System.out.printf("You need %.2f lv. more to buy the series!\n", Math.abs(budget));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement