Shalin Thanki
Badges: 3
Rep:
?
#1
Report Thread starter 1 year ago
#1
Can anyone help me convert my c# code into pseudocode for the exam???
Safe my g's x



using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace GCSE_PRE_RELEASE

{

class Program

{

static void Main(string[] args)

{

// TASK 1



char[] BusRoute = { 'A', 'B', 'C', 'D', 'E', 'F' };

string[] Day = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };

int DayNum = 0;

bool ErrorCheck = true;

int WeekNum = 1;

int NumOfDays = 20;

int[] BusA = { 0, 0, 0, 2, 2, 4, 0, 3, 4, -2, -5, 0, 0, 3, 4, -1, 8, 1, 1, -2 };

int[] BusB = { 0, 1, 0, 0, 1, 2, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 1, 0, 0 };

int[] BusC = { 2, 0, -1, -1, -2, -2, -3, -1, 0, 0, -2, 0, 1, 1, 1, 1, -1, -1, 2, -2 };

int[] BusD = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

int[] BusE = { -1, -1, -1, -2, -4, -10, -2, 0, 0, 0, 0, 1, 2, -3, 1, 1, 3, -1, 0, 0 };

int[] BusF = { 0, -5, -5, -5, -4, -3, -5, 0, 0, 0, 0, -2, -3, 1, 1, 1, 0, 0, -2, -5 };

int bored = int.Parse(Console.ReadLine());



if (bored == 1)

{

// BusA



for (int i = 0; i < NumOfDays; i++)

{

ErrorCheck = true;

while (ErrorCheck == true)

{

try

{

Console.WriteLine("Please enter Bus A's arrival score for Week {0}'s {1}", WeekNum, Day[DayNum]);

BusA[i] = int.Parse(Console.ReadLine());

if (BusA[i] >= -10 && BusA[i] <= 8)

{

DayNum++;

ErrorCheck = false;

}

else

{

Console.WriteLine("Invalid Value");

}

}

catch

{

Console.WriteLine("Invalid Value");

}

}

if (DayNum == 5)

{

DayNum = 0;

WeekNum++;

}

}



WeekNum = 1;



// BusB



for (int i = 0; i < NumOfDays; i++)

{

ErrorCheck = true;

while (ErrorCheck == true)

{

try

{

Console.WriteLine("Please enter Bus B's arrival score for Week {0}'s {1}", WeekNum, Day[DayNum]);

BusB[i] = int.Parse(Console.ReadLine());

if (BusB[i] >= -10 && BusB[i] <= 8)

{

DayNum++;

ErrorCheck = false;

}

else

{

Console.WriteLine("Invalid Value");

}

}

catch

{

Console.WriteLine("Invalid Value");

}

}

if (DayNum == 5)

{

DayNum = 0;

WeekNum++;

}

}



WeekNum = 1;



// BusC



for (int i = 0; i < NumOfDays; i++)

{

ErrorCheck = true;

while (ErrorCheck == true)

{

try

{

Console.WriteLine("Please enter Bus C's arrival score for Week {0}'s {1}", WeekNum, Day[DayNum]);

BusC[i] = int.Parse(Console.ReadLine());

if (BusC[i] >= -10 && BusC[i] <= 8)

{

DayNum++;

ErrorCheck = false;

}

else

{

Console.WriteLine("Invalid Value");

}

}

catch

{

Console.WriteLine("Invalid Value");

}

}

if (DayNum == 5)

{

DayNum = 0;

WeekNum++;

}

}



WeekNum = 1;



// BusD



for (int i = 0; i < NumOfDays; i++)

{

ErrorCheck = true;

while (ErrorCheck == true)

{

try

{

Console.WriteLine("Please enter Bus D's arrival score for Week {0}'s {1}", WeekNum, Day[DayNum]);

BusD[i] = int.Parse(Console.ReadLine());

if (BusD[i] >= -10 && BusD[i] <= 8)

{

DayNum++;

ErrorCheck = false;

}

else

{

Console.WriteLine("Invalid Value");

}

}

catch

{

Console.WriteLine("Invalid Value");

}

}

if (DayNum == 5)

{

DayNum = 0;

WeekNum++;

}

}



WeekNum = 1;



// BusE



for (int i = 0; i < NumOfDays; i++)

{

ErrorCheck = true;

while (ErrorCheck == true)

{

try

{

Console.WriteLine("Please enter Bus E's arrival score for Week {0}'s {1}", WeekNum, Day[DayNum]);

BusE[i] = int.Parse(Console.ReadLine());

if (BusE[i] >= -10 && BusE[i] <= 8)

{

DayNum++;

ErrorCheck = false;

}

else

{

Console.WriteLine("Invalid Value");

}

}

catch

{

Console.WriteLine("Invalid Value");

}

}

if (DayNum == 5)

{

DayNum = 0;

WeekNum++;

}

}



WeekNum = 1;



// BusF



for (int i = 0; i < NumOfDays; i++)

{

ErrorCheck = true;

while (ErrorCheck == true)

{

try

{

Console.WriteLine("Please enter Bus F's arrival score for Week {0}'s {1}", WeekNum, Day[DayNum]);

BusF[i] = int.Parse(Console.ReadLine());

if (BusF[i] >= -10 && BusF

[i] <= 8)

{

DayNum++;

ErrorCheck = false;

}

else

{

Console.WriteLine("Invalid Value");

}

}

catch

{

Console.WriteLine("Invalid Value");

}

}

if (DayNum == 5)

{

DayNum = 0;

WeekNum++;

}

}

}



// TASK 2



int BusALateNum = 0;

int BusBLateNum = 0;

int BusCLateNum = 0;

int BusDLateNum = 0;

int BusELateNum = 0;

int BusFLateNum = 0;

double TotalMinLate = 0;

double AvMinLate = 0.00;

double TotalMinLateLate = 0;

double AvMinLateLate = 0.00;



// Bus A



for (int i = 0; i < NumOfDays; i++)

{

TotalMinLate = TotalMinLate - BusA[i];

if (BusA[i] < 0)

{

BusALateNum++;

TotalMinLateLate = TotalMinLateLate - BusA[i];

}

}

AvMinLate = TotalMinLate / NumOfDays;

AvMinLateLate = TotalMinLateLate / BusALateNum;

Console.WriteLine("The number of late arrivals of Bus A = {0}, the average number of minutes late for all days = {1} and the average number of minutes late for the late days = {2}", BusALateNum, AvMinLate, AvMinLateLate);

TotalMinLate = 0;

TotalMinLateLate = 0;



// Bus B



for (int i = 0; i < NumOfDays; i++)

{

TotalMinLate = TotalMinLate - BusB[i];

if (BusB[i] < 0)

{

BusBLateNum++;

TotalMinLateLate = TotalMinLateLate - BusB[i];

}

}

AvMinLate = TotalMinLate / NumOfDays;

if (BusDLateNum == 0)

{

AvMinLateLate = 0;

}

else

{

AvMinLateLate = TotalMinLateLate / BusDLateNum;

}

Console.WriteLine("The number of late arrivals of Bus B = {0}, the average number of minutes late for all days = {1} and the average number of minutes late for the late days = {2}", BusBLateNum, AvMinLate, AvMinLateLate);

TotalMinLate = 0;

TotalMinLateLate = 0;



// Bus C



for (int i = 0; i < NumOfDays; i++)

{

TotalMinLate = TotalMinLate - BusC[i];

if (BusC[i] < 0)

{

BusCLateNum++;

TotalMinLateLate = TotalMinLateLate - BusC[i];

}

}

AvMinLate = TotalMinLate / NumOfDays;

AvMinLateLate = TotalMinLateLate / BusALateNum;

Console.WriteLine("The number of late arrivals of Bus C = {0}, the average number of minutes late for all days = {1} and the average number of minutes late for the late days = {2}", BusCLateNum, AvMinLate, AvMinLateLate);

TotalMinLate = 0;

TotalMinLateLate = 0;



// Bus D



for (int i = 0; i < NumOfDays; i++)

{

TotalMinLate = TotalMinLate - BusD[i];

if (BusD[i] < 0)

{

BusDLateNum++;

TotalMinLateLate = TotalMinLateLate - BusD[i];

}

}

AvMinLate = TotalMinLate / NumOfDays;

if (BusDLateNum == 0)

{

AvMinLateLate = 0;

}

else

{

AvMinLateLate = TotalMinLateLate / BusDLateNum;

}

Console.WriteLine("The number of late arrivals of Bus D = {0}, the average number of minutes late for all days = {1} and the average number of minutes late for the late days = {2}", BusDLateNum, AvMinLate, AvMinLateLate);

TotalMinLate = 0;

TotalMinLateLate = 0;



// Bus E



for (int i = 0; i < NumOfDays; i++)

{

TotalMinLate = TotalMinLate - BusE[i];

if (BusE[i] < 0)

{

BusELateNum++;

TotalMinLateLate = TotalMinLateLate - BusE[i];

}

}

AvMinLate = TotalMinLate / NumOfDays;

AvMinLateLate = TotalMinLateLate / BusELateNum;

Console.WriteLine("The number of late arrivals of Bus E = {0}, the average number of minutes late for all days = {1} and the average number of minutes late for the late days = {2}", BusELateNum, AvMinLate, AvMinLateLate);

TotalMinLate = 0;

TotalMinLateLate = 0;



// Bus F



for (int i = 0; i < NumOfDays; i++)

{

TotalMinLate = TotalMinLate - BusF[i];

if (BusF[i] < 0)

{

BusFLateNum++;

TotalMinLateLate = TotalMinLateLate - BusF[i];

}

}

AvMinLate = TotalMinLate / NumOfDays;

AvMinLateLate = TotalMinLateLate / BusFLateNum;

Console.WriteLine("The number of late arrivals of Bus F = {0}, the average number of minutes late for all days = {1} and the average number of minutes late for the late days = {2}", BusFLateNum, AvMinLate, AvMinLateLate);

TotalMinLate = 0;

TotalMinLateLate = 0;



if (BusALateNum >= BusBLateNum && BusALateNum >= BusCLateNum && BusALateNum >= BusDLateNum && BusALateNum >= BusELateNum && BusALateNum >= BusFLateNum)

{

Console.WriteLine("Bus A had the highest number -{0} on which it was late", BusALateNum);

}

if (BusBLateNum >= BusALateNum && BusBLateNum >= BusCLateNum && BusBLateNum >= BusDLateNum && BusBLateNum >= BusELateNum && BusBLateNum >= BusFLateNum)

{

Console.WriteLine("Bus B had the highest number -{0} on which it was late", BusBLateNum);

}

if (BusCLateNum >= BusBLateNum && BusCLateNum >= BusALateNum && BusCLateNum >= BusDLateNum && BusCLateNum >= BusELateNum && BusCLateNum >= BusFLateNum)

{

Console.WriteLine("Bus C had the highest number -{0} on which it was late", BusCLateNum);

}

if (BusDLateNum >= BusBLateNum && BusDLateNum >= BusCLateNum && BusDLateNum >= BusALateNum && BusDLateNum >= BusELateNum && BusDLateNum >= BusFLateNum)

{

Console.WriteLine("Bus D had the highest number -{0} on which it was late", BusDLateNum);

}

if (BusELateNum >= BusBLateNum && BusELateNum >= BusCLateNum && BusELateNum >= BusDLateNum && BusELateNum >= BusALateNum && BusELateNum >= BusFLateNum)

{

Console.WriteLine("Bus E had the highest number -{0} on which it was late", BusELateNum);

}

if (BusFLateNum >= BusBLateNum && BusFLateNum >= BusCLateNum && BusFLateNum >= BusDLateNum && BusFLateNum >= BusELateNum && BusFLateNum >= BusALateNum)

{

Console.WriteLine("Bus F had the highest number -{0} on which it was late", BusFLateNum);

}



// TASK 3

WeekNum = 0;

string DayChoiceNum = "";

while (ErrorCheck == true)

{

Console.WriteLine("Please enter a day in which you wish to inspect, enter the first 3 letters of the day and finish it with the week number, for example, Fri3");

try

{

string UserReqCheck = Console.ReadLine();

string DayChoiceCheck = UserReqCheck.Substring(0, 3);

string WeekChoiceCheck = UserReqCheck.Substring(3);

if ((WeekChoiceCheck == "1" || WeekChoiceCheck == "2" || WeekChoiceCheck == "3" || WeekChoiceCheck == "4") && (DayChoiceCheck == "Mon" || DayChoiceCheck == "Tue" || DayChoiceCheck == "Wed" || DayChoiceCheck == "Thu" || DayChoiceCheck == "Fri"))

{

DayChoiceNum = DayChoiceCheck;

WeekNum = int.Parse(WeekChoiceCheck);

ErrorCheck = false;

}

else

{

Console.WriteLine("Invalid Value");

}

}

catch { }

}

int NumOfLateBusses = 0;

int ArrayTableSearch = 0;

for (int i = 0; i < 5; i++)

{

if (DayChoiceNum == Day[i])

{

ArrayTableSearch = ArrayTableSearch + i;

}

}

WeekNum = WeekNum - 1;

ArrayTableSearch = ArrayTableSearch + (WeekNum * 5);

if (BusA[ArrayTableSearch] < 0)

{

NumOfLateBusses++;

Console.WriteLine("Bus A was late by {0} minutes", BusA[ArrayTableSearch]);

}

if (BusB[ArrayTableSearch] < 0)

{

NumOfLateBusses++;

Console.WriteLine("Bus B was late by {0} minutes", BusB[ArrayTableSearch]);

}

if (BusC[ArrayTableSearch] < 0)

{

NumOfLateBusses++;

Console.WriteLine("Bus C was late by {0} minutes", BusC[ArrayTableSearch]);

}

if (BusD[ArrayTableSearch] < 0)

{

NumOfLateBusses++;

Console.WriteLine("Bus D was late by {0} minutes", BusD[ArrayTableSearch]);

}

if (BusE[ArrayTableSearch] < 0)

{

NumOfLateBusses++;

Console.WriteLine("Bus E was late by {0} minutes", BusE[ArrayTableSearch]);

}

if (BusF[ArrayTableSearch] < 0)

{

NumOfLateBusses++;

Console.WriteLine("Bus F was late by {0} minutes", BusF[ArrayTableSearch]);

}

Console.WriteLine("A total of {0} busses were late", NumOfLateBusses);

Console.ReadLine();

}

}

}
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

Are you travelling in the Uni student travel window (3-9 Dec) to go home for Christmas?

Yes (48)
30.97%
No - I have already returned home (19)
12.26%
No - I plan on travelling outside these dates (33)
21.29%
No - I'm staying at my term time address over Christmas (14)
9.03%
No - I live at home during term anyway (41)
26.45%

Watched Threads

View All
Latest
My Feed