ivanmitkoff

Untitled

Jun 9th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class HotelRoom {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String month = scanner.nextLine();
  8.         int nights = Integer.parseInt(scanner.nextLine());
  9.  
  10.         double studioPrice = 0;
  11.         double apartmentPrice = 0;
  12.  
  13.         if (month.equals("May") || month.equals("October")) {
  14.             if (nights <= 7) {
  15.                 studioPrice = nights * 50;
  16.                 apartmentPrice = nights * 65;
  17.             } else if (nights > 7 && nights <= 14) {
  18.                 studioPrice = (nights * 50) - ((nights * 50) * 0.05);
  19.                 apartmentPrice = nights * 65;
  20.             } else if (nights > 14) {
  21.                 studioPrice = (nights * 50) - ((nights * 50) * 0.3);
  22.                 apartmentPrice = (nights * 65) - ((nights * 65) * 0.1);
  23.             }
  24.         } else if (month.equals("June") || month.equals("September")) {
  25.             if (nights <= 14) {
  26.                 studioPrice = nights * 75.20;
  27.                 apartmentPrice = nights * 68.70;
  28.             } else if (nights > 14) {
  29.                 studioPrice = (nights * 75.20) - ((nights * 75.20) * 0.2);
  30.                 apartmentPrice = (nights * 68.70) - ((nights * 68.70) * 0.1);
  31.             }
  32.         } else if (month.equals("July") || month.equals("August")) {
  33.             studioPrice = nights * 76;
  34.             apartmentPrice = nights * 77;
  35.             if (nights > 14) {
  36.                 apartmentPrice = (nights * 77) - ((nights * 77) * 0.1);
  37.             }
  38.         }
  39.         System.out.printf("Apartment: %.2f lv. %n", apartmentPrice);
  40.         System.out.printf("Studio: %.2f lv.", studioPrice);
  41.     }
  42. }
Add Comment
Please, Sign In to add comment