Advertisement
danisun18

Hotel Room

Feb 2nd, 2020
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 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 numberNights = Integer.parseInt(scanner.nextLine());
  8.  
  9. double priseStudio = 0.0;
  10. double priseApartment = 0.0;
  11. double discountStudio = 0.0;
  12. double discountApartment = 0.0;
  13. double totalStudio = 0.0;
  14. double totalApartment = 0.0;
  15.  
  16.  
  17. if (month.equals("May") || month.equals("October")) {
  18. priseStudio = 50;
  19. priseApartment = 65;
  20.  
  21. if (numberNights > 7 && numberNights <= 14) {
  22. discountStudio = 0.05;
  23. } else if (numberNights > 14) {
  24. discountStudio = 0.3;
  25. discountApartment = 0.1;
  26. }
  27. }
  28. if (month.equals("June") || month.equals("September")) {
  29. priseStudio = 75.20;
  30. priseApartment = 68.70;
  31.  
  32. if (numberNights > 14) {
  33. discountStudio = 0.20;
  34. discountApartment = 0.1;
  35. } else {
  36. }
  37. }
  38. if (month.equals("July") || month.equals("August")) {
  39. priseStudio = 76;
  40. priseApartment = 77;
  41.  
  42. if (numberNights > 14) {
  43. discountApartment = 0.1;
  44. } else {
  45. }
  46. }
  47. totalStudio = (priseStudio - priseStudio * discountStudio) * numberNights;
  48. totalApartment = (priseApartment - priseApartment * discountApartment) * numberNights;
  49.  
  50. System.out.printf("Apartment: %.2f lv. %n", totalApartment);
  51. System.out.printf("Studio: %.2f lv.", totalStudio);
  52.  
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement