Advertisement
Spocoman

Series

Sep 9th, 2024
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double budget = Double.parseDouble(scanner.nextLine()),
  7.                 price;
  8.         int volume = Integer.parseInt(scanner.nextLine());
  9.         String name;
  10.  
  11.         for (int i = 0; i < volume; i++) {
  12.             name = scanner.nextLine();
  13.             price = Double.parseDouble(scanner.nextLine());
  14.  
  15.             price *= switch (name) {
  16.                 case "Thrones" -> 0.5;
  17.                 case "Lucifer" -> 0.6;
  18.                 case "Protector" -> 0.7;
  19.                 case "TotalDrama" -> 0.8;
  20.                 case "Area" -> 0.9;
  21.                 default -> 1;
  22.             };
  23.  
  24.             budget -= price;
  25.         }
  26.  
  27.         if (budget >= 0) {
  28.             System.out.printf("You bought all the series and left with %.2f lv.\n", budget);
  29.         } else {
  30.             System.out.printf("You need %.2f lv. more to buy the series!\n", Math.abs(budget));
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement