Advertisement
Spocoman

Computer Room

Sep 3rd, 2024 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 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.         String month = scanner.nextLine();
  7.         int hours = Integer.parseInt(scanner.nextLine()),
  8.                 people = Integer.parseInt(scanner.nextLine());
  9.         String time = scanner.nextLine();
  10.         double price = 0;
  11.  
  12.         if (month.equals("march") || month.equals("april") || month.equals("may")) {
  13.             if (time.equals("day")) {
  14.                 price = 10.50;
  15.                 hours = 3;
  16.             } else {
  17.                 price = 8.40;
  18.             }
  19.         } else if (month.equals("june") || month.equals("july") || month.equals("august")) {
  20.             if (time.equals("day")) {
  21.                 price = 12.60;
  22.             } else {
  23.                 price = 10.20;
  24.             }
  25.         }
  26.  
  27.         if (people >= 4) {
  28.             price *= 0.9;
  29.         }
  30.  
  31.         if (hours >= 5) {
  32.             price /= 2;
  33.         }
  34.  
  35.         double total = price * people * hours;
  36.  
  37.         System.out.printf("Price per person for one hour: %.2f\n", price);
  38.         System.out.printf("Total cost of the visit: %.2f\n", total);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement