Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. clc
  2. close all
  3. clear all
  4. disp('week 4, ex.4')
  5. syms B
  6. syms C
  7. syms D
  8.  
  9. rp = input('Enter the rental period in days: ');
  10.  
  11. if rp > 60
  12. disp('Rental is not available for more than 60 days')
  13. break
  14. end
  15.  
  16. tc = input('Enter the type of a car (B, C or D): ');
  17.  
  18. if tc == B
  19. if rp < 7
  20. fprintf('The rental costs are %d€.',27*rp)
  21. elseif rp > 27
  22. if rp == 28
  23. fprintf('The rental costs are %d€.',662)
  24. else
  25. fprintf('The rental costs are %d€.',662+23*(rp-28))
  26. end
  27. else
  28. if rp == 7
  29. fprintf('The rental costs are %d€.',162)
  30. else
  31. fprintf('The rental costs are %d€.',162+25*(rp-7))
  32. end
  33. end
  34. end
  35.  
  36. if tc == C
  37. if rp < 7
  38. fprintf('The rental costs are %d€.',34*rp)
  39. elseif rp > 27
  40. if rp == 28
  41. fprintf('The rental costs are %d€.',884)
  42. else
  43. fprintf('The rental costs are %d€.',884+28*(rp-28))
  44. end
  45. else
  46. if rp == 7
  47. fprintf('The rental costs are %d€.',204)
  48. else
  49. fprintf('The rental costs are %d€.',204+31*(rp-7))
  50. end
  51. end
  52. end
  53.  
  54. if tc == D
  55. if rp < 7
  56. fprintf('Class D cars cannot be rented for less than 7 days')
  57. elseif rp > 27
  58. if rp == 28
  59. fprintf('The rental costs are %d€.',1136)
  60. else
  61. fprintf('The rental costs are %d€.',1136+38*(rp-28))
  62. end
  63. else
  64. if rp == 7
  65. fprintf('The rental costs are %d€.',276)
  66. else
  67. fprintf('The rental costs are %d€.',276+38*(rp-7))
  68. end
  69. end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement