deyanivanov966

EXAM 25.10 // 03. Computer Room

Oct 27th, 2020 (edited)
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. public class ComputerRoom {
  2.     public static void main(String[] args) {
  3.         Scanner scanner = new Scanner(System.in);
  4.         String month = scanner.nextLine();
  5.         int hoursSpend = Integer.parseInt(scanner.nextLine());
  6.         int numberOfPeople = Integer.parseInt(scanner.nextLine());
  7.         String dayTime = scanner.nextLine();
  8.         double pricePerPerson = 0.0;
  9.         double totalPrice = 0.0;
  10.  
  11.         switch (month) {
  12.             case "march":
  13.             case "april":
  14.             case "may":
  15.                 if (dayTime.equals("day")){
  16.                     pricePerPerson = 10.50;
  17.                 } else if (dayTime.equals("night")){
  18.                     pricePerPerson = 8.40;
  19.                 }
  20.                 break;
  21.  
  22.             case "june":
  23.             case "july":
  24.             case"august":
  25.                 if (dayTime.equals("day")){
  26.                     pricePerPerson = 12.60;
  27.                 } else if (dayTime.equals("night")){
  28.                     pricePerPerson = 10.20;
  29.                 }
  30.                 break;
  31.         }
  32.         if (numberOfPeople >= 4){
  33.             pricePerPerson = pricePerPerson * 0.90;
  34.         }
  35.         if (hoursSpend >= 5){
  36.             pricePerPerson = pricePerPerson * 0.50;
  37.         }
  38.         totalPrice = (pricePerPerson * numberOfPeople) * hoursSpend;
  39.         System.out.printf("Price per person for one hour: %.2f%n", pricePerPerson);
  40.         System.out.printf("Total cost of the visit: %.2f", totalPrice);
  41.  
  42.  
  43.     }
  44. }
Add Comment
Please, Sign In to add comment