Advertisement
Dido09

Ski Trip

Sep 30th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SkiTro {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int days = Integer.parseInt(scanner.nextLine());
  8. String roomType = scanner.nextLine();
  9. String evaluation = scanner.nextLine();
  10.  
  11. double priceForNight = 18;
  12. double percentage = 1;
  13.  
  14. if ("apartment".equals(roomType)){
  15. priceForNight = 25;
  16.  
  17. if(days < 10){
  18. percentage = 0.7;
  19. }else if (days <= 15){
  20. percentage = 0.65;
  21. }else{
  22. percentage = 0.5;
  23. }
  24. }else if("president apartment". equals(roomType)){
  25. priceForNight = 35;
  26.  
  27. if(days < 10){
  28. percentage = 0.9;
  29. }else if (days <= 15){
  30. percentage = 0.85;
  31. }else{
  32. percentage = 0.8;
  33. }
  34. }
  35. double totalPrice = priceForNight * (days - 1) * percentage;
  36.  
  37. if("positive".equals(evaluation)){
  38. totalPrice = totalPrice * 1.25;
  39. }else if("negative".equals(evaluation)){
  40. totalPrice = totalPrice * 0.9;
  41. }
  42. System.out.printf("%.2f",totalPrice);
  43.  
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement