Advertisement
Kancho

Hotel

Feb 1st, 2019
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. rt java.util.Scanner;
  2.  
  3. public class Hotel {
  4. public static void main(String[] args) {
  5.  
  6. Scanner keyboard = new Scanner(System.in);
  7. System.out.print("Enter month: ");
  8. String month = keyboard.next();
  9. System.out.print("Enter length of stay: ");
  10. int stay = keyboard.nextInt();
  11. switch (month) {
  12. case "May":
  13. case "October":
  14. if (stay <= 7) {
  15. double priceSt = stay * 50.0;
  16. double priceAp = stay * 65.0;
  17. System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
  18. } else if (7 < stay && stay <= 14) {
  19. double priceSt = (stay * 50.0) * 0.95;
  20. double priceAp = stay * 65.0;
  21. System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
  22. } else {
  23. double priceSt = (stay * 50.0) * 0.7;
  24. double priceAp = stay * 65.0 * 0.9;
  25. System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
  26. }
  27. break;
  28. case "July":
  29. case "September":
  30. if (stay <= 7) {
  31. double priceSt = stay * 72.5;
  32. double priceAp = stay * 68.7;
  33. System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
  34. } else if (7 <= stay && stay <=14) {
  35. double priceSt = (stay * 72.5) * 0.95;
  36. double priceAp = stay * 68.7;
  37. System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
  38. } else {
  39. double priceSt = (stay * 50.0) * 0.8;
  40. double priceAp = stay * 65.0 * 0.9;
  41. System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
  42. }
  43. break;
  44. case "June":
  45. case "August":
  46. if (stay <= 7) {
  47. double priceSt = stay * 76;
  48. double priceAp = stay * 77;
  49. System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
  50. }else if (7 < stay && stay <= 14){
  51. double priceSt = (stay * 76) * 0.95;
  52. double priceAp = (stay * 77);
  53. System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
  54. } else {
  55. double priceSt = (stay * 76) * 0.8;
  56. double priceAp = (stay * 77) * 0.9;
  57. System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
  58. }
  59. break;
  60. default: {
  61. System.out.println("We are closed");
  62. break;
  63. }
  64. }
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement