Begin Algorithm
//routeme application
//Declaring Variables
DECLARE Route1Time,Route1Total,NewRoute1total_time,Route2T ime,Route2Total,NewRoute2Total_time,RainyDay,Sunny Day,Day,Month,Week, totalDistanceRoute1, totalDistanceRoute2, leaving_time, CollectionOfPassengers,ArrivaltimeAS TYPE FLOAT
DECLARE WeekCount,MonthCount,DayCount,count, TypeOf Day AccidentTime,Route1Section_times,Route2section_tim es, Respective Route AS INTEGER
DECLARE Accident,timeleaving,weather, AS CHARACTER
//Declaring Arrays
Declare array Week 19 as type real
Declare Route1Section 16 as type real
Declare Route2Section 18 as type real
Declare week 19 as type real
Declare day 19 as type real
Declare routenum 19 as type real
Declare reasonrain 19 as type real
Declare accident 19 as type real
Declare reasontime 19 as type real
Declare CharMonth 10 as type real
Declare WeekCount
Declare DayCount
//Initialize Variables
WeekCount=DayCount=count
Accident = ‘’
// Calculations – 60km / 1000m = 0.06 m/s
//Time = (Distance in meters) x (0.06)
//All Route section times have been calculated here
Route1total=31.5
Route2total=31.6
Route1total=31.456
Route2total=31.613
leaving_time=0
Route1Section_times [0] = 0.2
Route1Section_times [1] = 0.1
Route1Section_times [2] = 0.8
Route1Section_times [3] = 2.4
Route1Section_times [4] = 7.8
Route1Section_times [5] = 1.7
Route1Section_times [6] = 4.7
Route1Section_times [7] = 0.4
Route1Section_times [8] = 6.8
Route1Section_times [9] = 0.7
Route1Section_times [10] = 2.1
Route1Section_times [11] = 0.3
Route1Section_times [12] = 0.6
Route1Section_times [13] = 0.2
Route1Section_times [14] = 2.6
Route1Section_times [15] = 0.1
Route2section_times 2 [0] = 0.2
Route2section_times [1] = 0.1
Route2section_times [2] = 0.1
Route2section_times [3] = 0.1
Route2section_times [4] = 2.4
Route2section_times [5] = 2.3
Route2section_times [6] = 2.6
Route2section_times [7] = 4.7
Route2section_times [8] = 0.4
Route2section_times [9] = 6.8
Route2section_times [10] = 0.7
Route2section_times [11] = 2.1
Route2section_times [12] = 0.9
Route2section_times [13] = 0.1
Route2section_times [14] = 2.8
Route2section_times [15] = 0.5
Route2section_times [16] = 1.0
Route2section_times [17] = 4.0
PRINT “Welcome To RouteMe!”
FOR Month = 1 to 12 DO
WHILE MonthCount < 1 AND MonthCount > 12
BEGIN
PRINT “Please enter month:”
READ MonthCount
IF MonthCount < 1 OR MonthCount > 12 THEN
PRINT “Month Invalid”
ENDIF
ENDWHILE
FOR Week = 1 to 4 DO
WHILE WeekCount < 1 AND WeekCount > 4
BEGIN
PRINT “Please Enter Week:”
READ WeekCount
IF WeekCount < 1 OR WeekCount > 4 THEN
PRINT “Week Invalid”
ENDIF
ENDWHILE FOR Day = 1 to 5 DO
WHILEDayCount < 1 AND DayCount > 5
BEGIN
PRINT “Enter Day Please:”
READ DayCount
IF DayCount < 1 OR DayCount > 5 THEN
PRINT “Day Is Invalid”
ENDIF
ENDWHILE
WHILE TypeOfDay < 1 OR TypeOfDay> 2 DO
BEGIN
PRINT “Please select Type of Day:”
PRINT “Enter 1 for SunnyDay or 2 for Rainyday”
READ TypeOfDay
IF TypeOfDay < 1 OR TypeOfDay> 2 THEN
PRINT “Your Selection Is Invalid”
ENDIF
If TypeofDay = ‘2’ then
RainyDay = 3*(Route1Section [13] + Route1Section [14] + Route1Section [15])
Print “Section time will triple because of rain”
Accident = Accident + RainyDay
Else if Weather = ‘1’
Print “No extra time is added along route ”
End If
ENDWHILE
IF TypeOfDay = 1 THEN
Selected Route = 1
WHILE (Accident !=’y’ OR Accident !=’Y’) OR (Accident !=’n’ OR Accident !=’N’) DO
BEGIN
PRINT “Is Accident on Route?”
PRINT “Select y for yes or n for no”
READ Accident
IF Accident !=’y’ OR Accident !=’Y’ OR Accident !=’n’ OR Accident !=’N’ THEN
PRINT “Your Selection is Invalid”
ENDIF
ENDWHILE
//Accident –which section has an accident, double the time for that section
IF Accident =’y’ OR Accident =’Y’ THEN
WHILE route < 1 OR route> 2 DO
BEGIN
PRINT “Which route Please?” (Prompting user to choose correct selection 1 or 2)
READ route_number
IF route < 1 OR route >2 THEN
PRINT “Your Selection Is invalid”
ENDIF
ENDWHILE
IF route = 1 THEN
Route1total= Route1section_times *2
ELSE
Route2total= Route2section_times *2
ENDIF
IF Route1total > Route2total THEN
Respected_route = 2
ENDIF
ENDIF // TypeOfDay
PRINT “What Is The Current Time?”
READ leaving_time
IF leaving_time < = 6.3 THEN
totalTime_route1 > totalTime_route2
Respective Route = 1
ELSE
Respective Route= 2
ENDIF
IF leaving_time > 6.3 THEN
NewRoute1total_time = (Route1total)*1.5
NewRoute2total_time = (Route2total)*1.5
IF NewRoute1total_time > NewRoute1total_time THEN
Respective_route = 1
ELSE
Respective_ route = 2
ENDIF
ENDIF// leaving_time
ENDIF
IF leaving_time > 6.3 THEN
NewRoute1total_time = (Route1total)*1.5
NewRoute2total_time = (Route2total)*1.5
IF NewRoute1total_time > NewRoute1total_time THEN
Respective_route = 1
ELSE
Respective_ route = 2
ENDIF
ENDIF// leaving_time
ENDIF
//Questions the time the user if collecting someone on route and Calculates 10 the extra time needed.
//Print “Are you collecting any passengers on route ? Y / N”
IF
Print “Are you sure?”
Input CollectionOf Passengers on route
If no
//If collecting someone = ‘n’ then
Print “No additional time calculated for early departure”
ReasonTime[Count] = 0
End If
//If collecting someone = ‘y’ then
If CollectionOfPassengers on route
Print “Additional time is needed “
ReasonTime[Count] = 1
Route1Total = Route1Time * 10
Route2Total = Route2Time* 10
End If
//Questions the time the user arrives at destination .
//Print “Did you arrive before 8.30? Y / N
Print “Input arrival time”
Input Arrival time
If Arrivaltime < 8:30 then
//If arrival time is before 8.30 =’N’
Print “You have made it on time”
ReasonTime[Count] = 0
End If
//If arrival time is after 8.30= ‘Y’ then
If Arrivaltime > 8:30
Print “Must leave home earlier tomorrow due to late arrival”
ReasonTime[Count] = 1
Arrivaltime = Route1Time * 10
Arrivaltime = Route2Time* 10
End If
//Final Calculations
Route1Total =CollectionOfpassengers+ Route1Total + AccidentExtendTime1
Route2Total = CollectionOfpassengers +Route2Total + AccidentExtendTime2
//Comparing
Print “Total route times :- Route 1=”, Route1Total ,”Route 2 = “, Route2Total
If Route1Total > Route2Total Then
Print “Use Route 2”
RouteNumber[Count] = 2
Else If Route1<Route2Total then
Print “Use Route 1”
RouteNumber[Count] = 1
Else
Print “Route 1 and Route 2 have the same time, choose either route”
RouteNumber[Count] = 3 //3 is either Route
End If
Print “Month :- “, Month
Print ”Week :- “, Week [weekcount]
Print “Day :- “, Day[Daycount]
Print “Route Taken :- “, RouteNumber [Count]
Print “y = Yes n = No”
Print “If Accident:- “, ReasonAccident[Count]
Print “If there was Rain:- “, ReasonRain[Count]
Print “If Late:- “, ReasonLate[Count]