Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 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. String month = scanner.nextLine();
  7. int nights = Integer.parseInt(scanner.nextLine());
  8. double priceApartment = 0;
  9. double priceStudio = 0;
  10.  
  11. if (month.equals("May") || month.equals("October")) {
  12. if (nights > 7 && nights <= 14) {
  13. priceApartment = 65 * nights;
  14. priceStudio = 50 * 0.95 * nights;
  15.  
  16. } else if (nights > 14) {
  17. priceApartment = 65 * 0.9 * nights;
  18. priceStudio = 50 * 0.7 * nights;
  19.  
  20. } else {
  21. priceApartment = 65 * nights;
  22. priceStudio = 50 * nights;
  23. }
  24. }
  25. if (month.equals("June") || month.equals("September")) {
  26. if (nights > 7 && nights <= 14) {
  27. priceApartment = 68.70 * nights;
  28. priceStudio = 75.20 * nights;
  29.  
  30. } else if (nights > 14) {
  31. priceApartment = 68.70 * 0.9 * nights;
  32. priceStudio = 75.20 * 0.8 * nights;
  33.  
  34. } else {
  35. priceApartment = 68.7 * nights;
  36. priceStudio = 75.20 * nights;
  37.  
  38. }
  39. }
  40. if (month.equals("July") || month.equals("August")) {
  41. if (nights > 7 && nights <= 14) {
  42. priceApartment = 77 * nights;
  43. priceStudio = 76 * nights;
  44.  
  45. } else if (nights > 14) {
  46. priceApartment = 77 * 0.9 * nights;
  47. priceStudio = 76 * nights;
  48.  
  49. } else {
  50. priceApartment = 77 * nights;
  51. priceStudio = 76 * nights;
  52.  
  53. }
  54. }
  55. System.out.printf("Apartment: %.2f lv.%n", priceApartment);
  56. System.out.printf("Studio: %.2f lv.", priceStudio);
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement