Advertisement
mahlichavpm

P07HotelRoom

Jul 3rd, 2021
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class O7HotelRoom {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. String month = scan.nextLine();
  8. int nights = Integer.parseInt(scan.nextLine());
  9.  
  10. double apartmentPrice = 0;
  11. double studioPrice = 0;
  12.  
  13. switch (month) {
  14. case "May":
  15. case "October":
  16. apartmentPrice = 65;
  17. studioPrice = 50;
  18. break;
  19. case "June":
  20. case "September":
  21. apartmentPrice = 68.70;
  22. studioPrice = 75.20;
  23. break;
  24. case "July":
  25. case "August":
  26. apartmentPrice = 77;
  27. studioPrice = 76;
  28. break;
  29. }
  30.  
  31. if (nights > 14) {
  32. apartmentPrice = apartmentPrice * 0.90;
  33. if (month.equals("May") || month.equals("October")) {
  34. studioPrice = studioPrice * 0.70;
  35. } else if (month.equals("June") || month.equals("September")) {
  36. studioPrice = studioPrice * 0.80;
  37. }
  38. } else if (nights > 7 && (month.equals("May") || month.equals("October"))) {
  39. studioPrice = studioPrice * 0.95;
  40. }
  41.  
  42. double sumApartment = apartmentPrice * nights;
  43. double sumStudio = studioPrice * nights;
  44.  
  45. System.out.printf("Apartment: %.2f lv.%n", sumApartment);
  46. System.out.printf("Studio: %.2f lv.%n", sumStudio);
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement