Advertisement
Silviyaa

Untitled

Mar 21st, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.26 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E03ComputerRoom {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String month = scanner.nextLine(); // "march", "april", "may", "june", "july", "august"
  8.         int numberHours = Integer.parseInt(scanner.nextLine());
  9.         int numberPerson = Integer.parseInt(scanner.nextLine());
  10.         String tomeDay = scanner.nextLine(); // "day" или "night"
  11.  
  12.         double price = 0;
  13.  
  14.         if ((month.equals("march") || (month.equals("april") || (month.equals("may"))))){
  15.             if(tomeDay.equals("day")){
  16.                 price = 10.50;
  17.                 if(numberPerson >= 4){
  18.                     price = 10.50 - 0.10;
  19.                 }
  20.                 if(numberHours >= 5){
  21.                     price = 10.50 - 0.50;
  22.                 }
  23.                 double totalPrice = (price * numberPerson) * numberHours;
  24.                 System.out.printf("Price per person for one hour: %.2f%n",price);
  25.                 System.out.printf("Total cost of the visit: %.2f",totalPrice);
  26.             }
  27.         }else if ((month.equals("june") || (month.equals("july") || (month.equals("august"))))){
  28.             if(tomeDay.equals("day")){
  29.                 price = 12.60;
  30.                 if(numberPerson >= 4){
  31.                     price =12.60 - 0.10;
  32.                 }
  33.                 if(numberHours >= 5){
  34.                     price = 12.60 - 0.50;
  35.                 }
  36.                 double totalPrice = (price * numberPerson) * numberHours;
  37.                 System.out.printf("Price per person for one hour: %.2f%n",price);
  38.                 System.out.printf("Total cost of the visit: %.2f",totalPrice);
  39.             }else if(tomeDay.equals("night")){
  40.                 price = 10.20;
  41.  
  42.                 if(numberPerson >= 4){
  43.                     price =10.20 - 0.9;
  44.                     //double sum = price;
  45.                 }
  46.                 if(numberHours >= 5){
  47.                     price = price - 0.5;
  48.                 }
  49.                 double totalPrice = (price * numberPerson) * numberHours;
  50.                 System.out.printf("Price per person for one hour: %.2f%n",price);
  51.                 System.out.printf("Total cost of the visit: %.2f",totalPrice);
  52.             }
  53.         }
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement