raliportokali

Untitled

May 13th, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SkiBreak {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. //1. крайна цена = броя нощувки * цена за нощувка
  7. //бр нощувки =дни - 1
  8. //цена за 1 нощувка-> зависи от типа на стаята
  9. //2.намалението
  10. //3.оценка
  11. int days = Integer.parseInt(scanner.nextLine());
  12. String roomType = scanner.nextLine();
  13. String grade = scanner.nextLine(); //positive or negative
  14. int nights = days -1; //нощувки
  15. //проверка за стаята
  16. double pricePerNight = 0;
  17. switch (roomType) {
  18. case "room for one person":
  19. pricePerNight = 18;
  20. break;
  21. case"apartment":
  22. pricePerNight = 25;
  23. break;
  24. case "president apartment":
  25. pricePerNight = 35;
  26. break;
  27. }
  28. double totalPrice = nights * pricePerNight;
  29. if (roomType.equals("apartment")) {
  30. if (days<10){
  31. //-30%
  32. totalPrice = totalPrice * 0.7;
  33. } else if (days >= 10 && days <= 15){
  34. //-35%
  35. totalPrice = totalPrice * 0.65;
  36. } else if (days > 15) {
  37. totalPrice = totalPrice * 0.5 *totalPrice;
  38. }
  39. }else if (roomType.equals("president apartment")) {
  40. if (days<10){
  41. //-10%
  42. totalPrice = totalPrice * 0.9;
  43. } else if (days >= 10 && days <= 15){
  44. //-15%
  45. totalPrice = totalPrice * 0.85;
  46. } else if (days > 15) {
  47. totalPrice = totalPrice * 0.8;
  48. }
  49.  
  50. }
  51. if (grade.equals("positive")) {
  52. totalPrice *=1.25;
  53.  
  54. }else if (grade.equals("negative")) {
  55. totalPrice = totalPrice * 0.9;
  56. }
  57. System.out.printf("%.2f", totalPrice);
  58.  
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment