Advertisement
Guest User

hotel room

a guest
Feb 2nd, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class HotelRoom {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. String month = scanner.nextLine();
  9. int nights = Integer.parseInt(scanner.nextLine());
  10. double studioPrice = 0;
  11. double apartmentPrice= 0;
  12.  
  13. if (month.equalsIgnoreCase("may") || month.equalsIgnoreCase("october")) {
  14. studioPrice = 50;
  15. apartmentPrice = 65;
  16.  
  17. if (nights > 14) {
  18. studioPrice *= 0.70;
  19. } else if (nights > 7) {
  20. studioPrice *= 0.95;
  21. }
  22. } else if (month.equalsIgnoreCase("june") || month.equalsIgnoreCase("september")) {
  23. studioPrice = 75.20;
  24. apartmentPrice = 68.70;
  25. if (nights > 14) {
  26. studioPrice *= 0.80;
  27. }
  28. } else if (month.equalsIgnoreCase("july") || month.equalsIgnoreCase("august")) {
  29. studioPrice = 76;
  30. apartmentPrice = 77;
  31. }
  32. if (nights > 14) {
  33. apartmentPrice *= 0.90;
  34. }
  35. double apartamentTotal = apartmentPrice * nights;
  36. double studioTotal = studioPrice * nights;
  37. System.out.printf("Apartment: %.2f lv.%n", apartamentTotal);
  38. System.out.printf("Studio: %.2f lv.", studioTotal);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement