Advertisement
veronikaaa86

13. Ski Trip

Mar 22nd, 2021
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. package conditionalStatementsAdvanced;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P12SkiTrip {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int days = Integer.parseInt(scanner.nextLine());
  10. String type = scanner.nextLine();
  11. String grade = scanner.nextLine();
  12.  
  13. int nights = days - 1;
  14.  
  15. double result = 0;
  16. if (type.equals("room for one person")) {
  17. result = 18 * nights;
  18. } else if (type.equals("apartment")) {
  19. result = 25 * nights;
  20.  
  21. if (days < 10) {
  22. result = result * 0.7;
  23. } else if (days < 15) {
  24. result = result * 0.65;
  25. } else if (days > 15) {
  26. result = result * 0.5;
  27. }
  28. } else if (type.equals("president apartment")) {
  29. result = 35 * nights;
  30.  
  31. if (days < 10) {
  32. result = result * 0.90;
  33. } else if (days < 15) {
  34. result = result * 0.85;
  35. } else if (days > 15) {
  36. result = result * 0.80;
  37. }
  38. }
  39.  
  40. if (grade.equals("positive")) {
  41. result = result * 1.25;
  42. } else {
  43. result = result * 0.90;
  44. }
  45.  
  46. System.out.printf("%.2f", result);
  47. }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement