Guest_imported
New member
- Jan 1, 1970
- 0
hi all,
I am trying to make a program that will allow users to add a course if it does not conflict with any existing course. The program should then check with the existing two courses to see if there is a conflict in time. If there is a conflict, the course will not be added, otherwise added. Finally the updated course list will be displayed.
This is what I got so far and I have reach my limit.
The problem I have is getting C++ to check to see if the time the user input is in conflict with with any existing course.Other than that I know how to do.I have tried the if-statement but with no luck.Can anyone help me out here?
#include<iostream>
struct Time
{ int Hrs;
int Mins;
};
{
char CourseID[10];
Time StartTime;
int Length;
};
Time SetTime();
void PrintTime(Time );
void main()
{//Declaration of an array of type Course of size 5 with first two elements initialized.
Course Current[5] = { {"MTH101", 9, 30, 75}, {"M212", 14, 0, 110} };
cout<<"\nEnter course number: ";
cin>>Current[2].CourseID;
Current[2].StartTime = SetTime();
cout<<"\nEnter the length in minutes: ";
cin>>Current[2].Length;
}
//function definitions
Time SetTime()
{ Time T;
cout <<"Enter hours (in military) and minutes separated by a space: ";
cin >> T.Hrs >> T.Mins;
return T;
}
void PrintTime(Time T)
{ if (T.Hrs != 12)
cout << T.Hrs%12 <<':';
else
cout <<T.Hrs <<':';
if (T.Mins < 10 )
cout << '0' <<T.Mins;
else
cout << T.Mins;
if (T.Hrs < 12)
cout <<" AM";
else
cout <<" PM";
}
I am trying to make a program that will allow users to add a course if it does not conflict with any existing course. The program should then check with the existing two courses to see if there is a conflict in time. If there is a conflict, the course will not be added, otherwise added. Finally the updated course list will be displayed.
This is what I got so far and I have reach my limit.
The problem I have is getting C++ to check to see if the time the user input is in conflict with with any existing course.Other than that I know how to do.I have tried the if-statement but with no luck.Can anyone help me out here?
#include<iostream>
struct Time
{ int Hrs;
int Mins;
};
{
char CourseID[10];
Time StartTime;
int Length;
};
Time SetTime();
void PrintTime(Time );
void main()
{//Declaration of an array of type Course of size 5 with first two elements initialized.
Course Current[5] = { {"MTH101", 9, 30, 75}, {"M212", 14, 0, 110} };
cout<<"\nEnter course number: ";
cin>>Current[2].CourseID;
Current[2].StartTime = SetTime();
cout<<"\nEnter the length in minutes: ";
cin>>Current[2].Length;
}
//function definitions
Time SetTime()
{ Time T;
cout <<"Enter hours (in military) and minutes separated by a space: ";
cin >> T.Hrs >> T.Mins;
return T;
}
void PrintTime(Time T)
{ if (T.Hrs != 12)
cout << T.Hrs%12 <<':';
else
cout <<T.Hrs <<':';
if (T.Mins < 10 )
cout << '0' <<T.Mins;
else
cout << T.Mins;
if (T.Hrs < 12)
cout <<" AM";
else
cout <<" PM";
}