Problem Statement
This program determines the total amount of rental fee paid by the company. The
algorithm should include the model of a car from 3 models of vehicles listed from the
model table in the spreadsheet section. The user should input the model of the car
rented that is one listed in the table and count the number of cars of each model rented.
Calculate and print the total rental (without the incentive) for all of the vehicles rented
determined from the spreadsheet table.
1
IPO Chart
Input Processing Output
CarModel Read CarModel TotalFee
IF CarModel= “camry” then add 1 to camrycount
IF CarModel= “yaris” then add 1 to yariscount
IF CarModel= “corolla” then add 1 to corollacount
REPEAT previous steps until CarModel= “End”
TotalFee= (camrycount*4000)+(yariscount*2000)+
(corollacount*3500)
Print TotalFee
2
Data Dictionary
Variable Name Variable Type Variable Description
CarModel string Stores the car model entered by the user
camrycount integer Counter for number of camry cars
yariscount integer Counter for number of yaris cars
corollacount integer Counter for number of corolla cars
TotalFee real Stores the total Rental fee of the
approved cars
3
Algorithm
Begin
WHILE CarModel= “End” DO
Read CarModel
IF CarModel= “camry” then add 1 to camrycount
IF CarModel= “yaris” then add 1 to yariscount
IF CarModel= “corolla” then add 1 to corollacount
ENDWHILE
TotalFee=(camrycount*4000)+(yariscount*2000)+
(corollacount*3500)
Print TotalFee
4
Trace Table
Statement camrycount yariscount corollacount Output
camrycount=0
yariscount=0
corollacount=0
CarModel= "End"? No
CarModel= camry? Yes
camrycount=0+1
Print camrycount 1
CarModel= "End"? No
CarModel= camry? No
CarModel= yaris? Yes
yariscount=0+1
Print yarriscount 1
CarModel= "End"? No
CarModel= camry? No
CarModel= yaris? No
CarModel= corolla? Yes
corollacount=0+1
Print corollacount 1
CarModel= "End"? No
CarModel= camry? No
CarModel= yaris? Yes
yariscount=1+1
Print yarriscount 2
CarModel= "End"? No
CarModel= camry? No
CarModel= yaris? Yes
yariscount=2+1
Print yarriscount 3
CarModel= "End"? No
CarModel= camry? No
CarModel= yaris? No
CarModel= corolla? Yes
corollacount=1+1
Print corollacount 2
CarModel= "End"? No
CarModel= camry? Yes
5
camrycount=1+1
Print camrycount 2
CarModel= "End"? Yes
TotalFee= (camrycount*4000)+(yariscount*2000)+
(corollacount*3500
Print TotalFee 21000
6
Pascal Program
{Authors: Daniel Sookhai, Nicolai Moore, Katja Singh, Suri Jagoo}
{Date: 06/26/2024}
{Problem: The program calculates total rental fees based on user-inputted car models
and quantities, using predefined pricing from a table.}
Program CalcTotal;
Var
CarModel:string;
camrycount,yariscount,corollacount:integer;
TotalFee:real;
Begin
camrycount:=0;
yariscount:=0;
corollacount:=0;
TotalFee:= 0.00;
Writeln('Enter Car Model:camry or yaris or corolla. Enter End to stop ');
Readln(CarModel);
WHILE(CarModel <> 'End')DO
begin
IF(CarModel='camry')THEN
camrycount:= camrycount+1;
IF(CarModel='yaris')THEN
yariscount:= yariscount+1;
IF(CarModel='corolla')THEN
corollacount:= corollacount+1;
7
Writeln('Enter Car Model:camry or yaris or corolla. Enter End to stop ');
Readln(CarModel);
end;
TotalFee:=(camrycount*4000)+(yariscount*2000)+(corollacount*3500);
Writeln('Total camry cars ',camrycount);
Writeln('Total yaris cars ',yariscount);
Writeln('Total corolla cars ',corollacount);
Writeln('The Total fee for all model of cars is $',TotalFee:8:2);
END.
8
9
Output
10