desislava_topuzakova

03. Movie Destination

Feb 19th, 2022
1,163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.23 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MovieDestination_03 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         //обща сума за филм = бр. дни * цена за 1 ден (зависи от сезон и дестинация)
  7.  
  8.         double budget = Double.parseDouble(scanner.nextLine());
  9.         String destination = scanner.nextLine();
  10.         //"Dubai", "Sofia" и "London"
  11.         String season = scanner.nextLine();
  12.         //"Summer" и "Winter"
  13.         int count = Integer.parseInt(scanner.nextLine());
  14.  
  15.         double pricePerDay = 0; //цена за 1 ден
  16.         if (season.equals("Summer")) {
  17.             //лято -> проверка за дестинацията
  18.             if (destination.equals("Dubai")) {
  19.                 pricePerDay = 40000;
  20.             } else if (destination.equals("Sofia")) {
  21.                 pricePerDay = 12500;
  22.             } else if (destination.equals("London")) {
  23.                 pricePerDay = 20250;
  24.             }
  25.         } else if (season.equals("Winter")) {
  26.             //зима
  27.             if (destination.equals("Dubai")) {
  28.                 pricePerDay = 45000;
  29.             } else if (destination.equals("Sofia")) {
  30.                 pricePerDay = 17000;
  31.             } else if (destination.equals("London")) {
  32.                 pricePerDay = 24000;
  33.             }
  34.         }
  35.  
  36.         double totalSum = count * pricePerDay; //обща сума за филма
  37.  
  38.         //отстъпки / облагания
  39.         if (destination.equals("Dubai")) {
  40.             totalSum = totalSum - 0.3 * totalSum; //0.7 * totalSum
  41.         } else if (destination.equals("Sofia")) {
  42.             totalSum = totalSum + 0.25 * totalSum; // 1.25 * totalSum
  43.         }
  44.  
  45.         if (budget >= totalSum) {
  46.             //достатъчен
  47.             double leftBudget = budget - totalSum;
  48.             System.out.printf("The budget for the movie is enough! We have %.2f leva left!", leftBudget);
  49.         } else {
  50.             //не е достатъчен
  51.             //budget < totalSum
  52.             double needSum = totalSum - budget;
  53.             System.out.printf("The director needs %.2f leva more!", needSum);
  54.         }
  55.  
  56.     }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment