Advertisement
Ligh7_of_H3av3n

03.ComputerRoom

Oct 21st, 2023
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. package ZadachiOtIzpita2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ComputerRoom {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String month = scanner.nextLine();
  10.         int hours = Integer.parseInt(scanner.nextLine());
  11.         int groupSize = Integer.parseInt(scanner.nextLine());
  12.         String dayTime = scanner.nextLine();
  13.  
  14.         double price = 0;
  15.  
  16.  
  17.         switch (month) {
  18.             case "march":
  19.             case "april":
  20.             case "may":
  21.             {
  22.                 switch (dayTime) {
  23.                     case "day":
  24.                         price = 10.5;
  25.                         break;
  26.                     case "night":
  27.                         price = 8.4;
  28.                         break;
  29.                 }break;
  30.             }
  31.             case "june":
  32.             case "july":
  33.             case "august":
  34.                 switch (dayTime) {
  35.                     case "day":
  36.                         price = 12.6;
  37.                         break;
  38.                     case "night":
  39.                         price = 10.2;
  40.                         break;
  41.                 }break;
  42.         }
  43.         if (groupSize >= 4) {
  44.             price *= 0.9;
  45.         }
  46.  
  47.         if (hours >= 5) {
  48.             price *= 0.5;
  49.         }
  50.         double totalPrice = price * groupSize * hours;
  51.  
  52.         System.out.printf("Price per person for one hour: %.2f\n", price);
  53.         System.out.printf("Total cost of the visit: %.2f", totalPrice);
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement