im pretty new to c++ and ive been tasked to make a booking system as a mini project for school it would be great if someone could help me fix this mess that is far too many for loops for a basic booking system and tell me how id somehow make these arrays read from a text file so that it replaces the times if someone has already booked. thanks in advance
void Booking()
{
string booked;
string timeBooked;
//Sets the week and time array
string Monday[11] = { "Monday :","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm" };
string Tuesday[11] = { "Tuesday :","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm" };
string Wednesday[11] = { "Wednesday:","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm" };
string Thursday[11] = { "Thursday :","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm" };
string Friday[11] = { "Friday :","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm" };
string Saturday[11] = { "Saturday :","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm" };
string Sunday[11] = { "Sunday :","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm" };
// Create and open a text file
ofstream MyFile("Booking.txt");
//Outputs a statment line for the day and time
cout << "Available Times for next weeks driving lessons:" << endl;
//runs through both day and time array to create a timetable of dates
for (int i = 0; i < 11; i++)
{
cout << Monday[i] << " ";
}
cout << endl;
for (int i = 0; i < 11; i++)
{
cout << Tuesday[i] << " ";
}
cout << endl;
for (int i = 0; i < 11; i++)
{
cout << Wednesday[i] << " ";
}
cout << endl;
for (int i = 0; i < 11; i++)
{
cout << Thursday[i] << " ";
}
cout << endl;
for (int i = 0; i < 11; i++)
{
cout << Friday[i] << " ";
}
cout << endl;
for (int i = 0; i < 11; i++)
{
cout << Saturday[i] << " ";
}
cout << endl;
for (int i = 0; i < 11; i++)
{
cout << Sunday[i] << " ";
}
cout << endl << endl;
bool valid = false;
while (valid == false)
{
//Asks the user to input their wanted day
cout << "Please select an available day you wish to book: ";
cin >> booked;
if (booked != "Monday")
{
if (booked != "Tuesday")
{
if (booked != "Wednesday")
{
if (booked != "Thursday")
{
if (booked != "Friday")
{
if (booked != "Saturday")
{
if (booked != "Sunday")
{
cout << "Please enter a valid day" << endl;
}
else
{
valid = true;
}
}
else
{
valid = true;
}
}
else
{
valid = true;
}
}
else
{
valid = true;
}
}
else
{
valid = true;
}
}
else
{
valid = true;
}
}
else
{
valid = true;
}
}
valid = false;
while (valid == false)
{
cout << "Please enter the time you wish to book (Time am/pm E.g 2pm): ";
cin >> timeBooked;
for (int i = 0; i < 11; i++)
{
if (timeBooked == Monday[i])
{
valid = true;
if (booked == "Monday")
{
Monday[i] = "Unavailable";
}
else
{
if (booked == "Tuesday")
{
Tuesday[i] = "Unavailable";
}
else
{
if (booked == "Wednesday")
{
Wednesday[i] = "Unavailable";
}
else
{
if (booked == "Thursday")
{
Thursday[i] = "Unavailable";
}
else
{
if (booked == "Friday")
{
Friday[i] = "Unavailable";
}
else
{
if (booked == "Saturday")
{
Saturday[i] = "Unavailable";
}
else
{
if (booked == "Sunday")
{
Sunday[i] = "Unavailable";
}
else
{
}
}
}
}
}
}
}
}
}
}
for (int i = 0; i < 11; i++)
{
MyFile << Monday[i];
}
for (int i = 0; i < 11; i++)
{
MyFile << Tuesday[i];
}
}