Advertisement
veronikaaa86

09. Ski Trip

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