ralitsa_d

HotelRoom

Feb 8th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P03_HotelRoom {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. String month = scan.nextLine();
  8. int days = Integer.parseInt(scan.nextLine());
  9.  
  10. double studioPrice = 0, apartmentPrice = 0;
  11.  
  12. switch (month) {
  13. case "May":
  14. case "October":
  15. if(days > 7 && days <= 14){
  16. studioPrice = 50 * 0.95;
  17. } else if (days > 14){
  18. studioPrice = 50 * 0.7;
  19. } else {
  20. studioPrice = 50;
  21. }
  22.  
  23. apartmentPrice = 65;
  24.  
  25. break;
  26. case "June":
  27. case "September":
  28. if(days > 14){
  29. studioPrice = 75.20 * 0.8;
  30. } else {
  31. studioPrice = 75.20;
  32. }
  33.  
  34. apartmentPrice = 68.70;
  35. break;
  36. default:
  37. studioPrice = 76;
  38. apartmentPrice = 77;
  39. break;
  40. }
  41.  
  42. if(days > 14){
  43. apartmentPrice *= 0.9;
  44. }
  45.  
  46. double totalPriceApartment = days * apartmentPrice;
  47. double totalPriceStudio = days * studioPrice;
  48.  
  49. System.out.printf("Apartment: %.2f lv.\n", totalPriceApartment);
  50. System.out.printf("Studio: %.2f lv.", totalPriceStudio);
  51.  
  52. }
  53. }
Add Comment
Please, Sign In to add comment