desislava_topuzakova

Untitled

Nov 14th, 2021
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. Вероника, [11/14/2021 1:36 PM]
  2. package exerciseAdvConditionalStatements;
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class P09SkiTrip {
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10. int days = Integer.parseInt(scanner.nextLine());
  11. String roomType = scanner.nextLine();
  12. String evaluation = scanner.nextLine();
  13.  
  14. double price = 0.0;
  15. double moneyForTrip = 0;
  16.  
  17. switch (roomType) {
  18. case "room for one person":
  19. if (days < 10) {
  20. price = 18;
  21. } else if (days <= 15) {
  22. price = 18;
  23. } else {
  24. price = 18;
  25. }
  26. break;
  27. case "apartment":
  28. if (days < 10) {
  29. price = 25 * 0.7;
  30. } else if (days <= 15) {
  31. price = 25 * 0.65;
  32. } else {
  33. price = 25 * 0.5;
  34. }
  35. break;
  36. case "president apartment":
  37. if (days < 10) {
  38. price = 35 * 0.9;
  39. } else if (days <= 15) {
  40. price = 35 * 0.85;
  41. } else {
  42. price = 35 * 0.8;
  43. }
  44. break;
  45. }
  46. moneyForTrip = (days - 1) * price;
  47. if ("positive".equals(evaluation)) {
  48. moneyForTrip = moneyForTrip * 1.25;
  49. } else {
  50. moneyForTrip = moneyForTrip * 0.9;
  51. }
  52. System.out.printf("%.2f", moneyForTrip);
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment