Advertisement
galinyotsev123

ProgBasicsExam1and2December2018-E03skiTrip

Dec 29th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E03skiTrip {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double roomForOnePerson = 18.00;
  8. double apartment = 25.00;
  9. double presidentApartment = 35.00;
  10.  
  11. double days = Double.parseDouble(scanner.nextLine());
  12. String type = scanner.nextLine();
  13. String feedback = scanner.nextLine();
  14.  
  15. double nights = days - 1;
  16.  
  17. double sum = 0;
  18. double sumAfterDiscount = 0;
  19. double sumAfterFeedback = 0;
  20.  
  21. if (type.equalsIgnoreCase("apartment")) {
  22. sum = nights * apartment;
  23. if (nights < 10){
  24. sum = sum * 0.70;
  25. }
  26. else if (nights > 10 && nights <=15){
  27. sumAfterDiscount = sum * 0.65;
  28. }
  29. else if (nights > 15){
  30. sumAfterDiscount = sum * 0.50;
  31. }
  32. }
  33.  
  34. else if (type.equalsIgnoreCase("room for one person")) {
  35. sum = nights * roomForOnePerson;
  36. sumAfterDiscount = sum;
  37. }
  38.  
  39. else if (type.equalsIgnoreCase("president apartment")) {
  40. sum = nights * presidentApartment;
  41. if (nights < 10){
  42. sum = sum * 0.90;
  43. }
  44. else if (nights > 10 && nights <=15){
  45. sumAfterDiscount = sum * 0.85;
  46. }
  47. else if (nights > 15){
  48. sumAfterDiscount = sum * 0.80;
  49. }
  50. }
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. if (feedback.equalsIgnoreCase("positive")){
  58. sumAfterFeedback = sumAfterDiscount * 1.25;
  59. }
  60. else if (feedback.equalsIgnoreCase("negative")){
  61. sumAfterFeedback = sumAfterDiscount * 0.90;
  62. }
  63.  
  64. System.out.printf("%.2f",sumAfterFeedback);
  65.  
  66.  
  67.  
  68. }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement