Advertisement
Valantina

Series

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