Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- close all
- clear all
- disp('week 4, ex.4')
- syms B
- syms C
- syms D
- rp = input('Enter the rental period in days: ');
- if rp > 60
- disp('Rental is not available for more than 60 days')
- break
- end
- tc = input('Enter the type of a car (B, C or D): ');
- if tc == B
- if rp < 7
- fprintf('The rental costs are %d€.',27*rp)
- elseif rp > 27
- if rp == 28
- fprintf('The rental costs are %d€.',662)
- else
- fprintf('The rental costs are %d€.',662+23*(rp-28))
- end
- else
- if rp == 7
- fprintf('The rental costs are %d€.',162)
- else
- fprintf('The rental costs are %d€.',162+25*(rp-7))
- end
- end
- end
- if tc == C
- if rp < 7
- fprintf('The rental costs are %d€.',34*rp)
- elseif rp > 27
- if rp == 28
- fprintf('The rental costs are %d€.',884)
- else
- fprintf('The rental costs are %d€.',884+28*(rp-28))
- end
- else
- if rp == 7
- fprintf('The rental costs are %d€.',204)
- else
- fprintf('The rental costs are %d€.',204+31*(rp-7))
- end
- end
- end
- if tc == D
- if rp < 7
- fprintf('Class D cars cannot be rented for less than 7 days')
- elseif rp > 27
- if rp == 28
- fprintf('The rental costs are %d€.',1136)
- else
- fprintf('The rental costs are %d€.',1136+38*(rp-28))
- end
- else
- if rp == 7
- fprintf('The rental costs are %d€.',276)
- else
- fprintf('The rental costs are %d€.',276+38*(rp-7))
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement