SHARE
TWEET

Series

Valantina Jun 18th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top