diff --git a/Timetable application b/Timetable application new file mode 100644 index 0000000..c76f3e7 --- /dev/null +++ b/Timetable application @@ -0,0 +1,150 @@ +#include + +#include +using namespace std; + +//I have chosen to use arrays in order to create the timetable, I have used for loops to go through each element of the array and +////if statements to check them. I have also used the break statement in order to stop the loop iteration where needed. +////The switch statement was used as well because I had multiple conditions and I wanted to perform a different action based o the condition +// The user needs to enter an hour and a day and the program will tell them the class that is +//taking place during that time and day +// + +//As tutorials, I have watched youtube videos which I found very useful. FreeCodeCamp and CodeBeauty helped me understand +//the importance of the arrays and how powerful they can be +//I also understood the strong connection between the arrays and the pointers, however, knowing that pointers are a +//powerful tool, I have decided not to use them.The links are below: +//https://www.youtube.com/watch?v=mGl9LO-je3o&t=96s&ab_channel=CodeBeauty +//https://www.youtube.com/watch?v=vLnPwxZdW4Y&t=10406s&ab_channel=freeCodeCamp.org +//I have compiled the code and tested it and ran it, it works as expected. To compile it, I have used the command "g++ -std=c++14" + + +int Time[8] = { 8,9,10,11,12,14,15,16 }; +string Day[6] = { "Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" }; + +string Monday[8] = { "Computer architecture", + "Mathematics", + "Software design", + "Activity LED project", + "Programming and algorithms", + "Add-Vantage Module", + "Object oriented programming", + "Database Systems" }; +string Tuesday[8] = { "Introduction in Artificial intelligence", + "Mathematics", + "Software engineering", + "Theory of computation", + "Advanced algorithms", + "Operating systems and security", + "Big data programming project", + "Programming and algorithms" }; +string Wednesday[8] = { "Data science", + "Big Data programming projects", + "Mathematics","Add-vantage module", + "Programming and algorithms", + "Object oriented programming", + "Professional training", + "Big data programming project" }; +string Thursday[8] = { "Software design", + "Computer architecture", + "Mathematics", + "Introduction in artifial intelligence", + "Programming and algorithms", + "Add-Vantage module", + "Security", + "Machine learning and related applications" }; +string Friday[8] = { "Object oriented programming", + "Software design","Mathematics", + "Add-vantage module", + "Programming and algorithms", + "Computer architecture","Mobile applications development", + "Individual project preparation" }; +string Saturday[8] = { "Computer architecture", + "Programming and algorithms", + "Mathematics", + "Object oriented programming", + "Database systems", + "Activity LED project", + "Professional training", + "Add-vantage module" }; + +int main() +{ + int time; + string day; + + cout << "Which time do you want to know the timetable for? " << endl; + cin >> time; + + cout << " Which day do you want to know the timetable for?"; + cin >> day; + + + bool foundday = false; + bool foundtime = false; + int timesub = 0; + int daysub = 0; + + for (timesub = 0; timesub < 8; timesub++) + { + if (Time[timesub] == time) + { + foundtime = true; + break; + } + } + + for (daysub = 0; daysub < 6; daysub++) + { + if (Day[daysub] == day) + { + foundday = true; + break; + } + } + + if (!foundday || !foundtime) + { + cout << "I'm sorry, the day you selected has no active classes\n"; + ; + return 0; + } + + string activity; + string next; + + switch (daysub) + { + case 0: activity = Monday [timesub]; + if (timesub < 7) next = Monday [timesub+1]; + break; + + case 1: activity = Tuesday [timesub]; + if (timesub < 7) next = Tuesday [timesub+1]; + break; + + case 2: activity = Wednesday[timesub]; + if (timesub < 7) next = Wednesday[timesub+1]; + break; + + case 3: activity = Thursday [timesub]; + if (timesub < 7) next = Thursday [timesub+1]; + break; + + case 4: activity = Friday [timesub]; + if (timesub < 7) next = Friday [timesub+1]; + break; + + case 5: activity = Saturday [timesub]; + if (timesub < 7) next = Saturday [timesub+1]; + break; + + default: activity = "We couldn't find the day you selected"; + break; + } + + cout << activity << " " << next << '\n'; + + + +}