How do I use enumeration to solve this problem in C++ ?

Create a for loop that will print out what courses you've completed and what courses you have not instead of the 8 output lines in the original code. Only the programming course should print out as completed course like it is in the original code and all others should print not completed.

#include <iostream>

using namespace std;

int main()
{
const int SIZE=8;
typedef double list[SIZE];
list prereqs;

enum courses { ENGL, MATH, ITSC, COSC, ACNT, BIOL, CHEM, ENGR };
courses myDegree;

for ( myDegree=ENGL;myDegree<= ENGR; myDegree=static_cast<courses>(myDegree+1…
prereqs[myDegree] = 0.0;
}

myDegree=ENGL;
prereqs[3] = 1.0;
(prereqs[myDegree] == 0.0)?cout<<"Not yet completed English"<<endl:cout<<"Done with English"<<endl;
(prereqs[myDegree=static_cast<courses>(m… == 0.0)?cout<<"Not yet completed Math"<<endl:cout<<"Done with Math"<<endl;
(prereqs[myDegree=static_cast<courses>(m… == 0.0)?cout<<"Not yet completed IT courses"<<endl:cout<<"Done with IT courses"<<endl;
(prereqs[myDegree=static_cast<courses>(m… == 0.0)?cout<<"Not yet completed Programming"<<endl:cout<<"Done with Programming"<<endl;
(prereqs[myDegree=static_cast<courses>(m… == 0.0)?cout<<"Not yet completed Accounting"<<endl:cout<<"Done with Accounting"<<endl;
(prereqs[myDegree=static_cast<courses>(m… == 0.0)?cout<<"Not yet completed Biology"<<endl:cout<<"Done with Biology"<<endl;
(prereqs[myDegree=static_cast<courses>(m… == 0.0)?cout<<"Not yet completed Chemistry"<<endl:cout<<"Done with Chemistry"<<endl;
(prereqs[myDegree=static_cast<courses>(m… == 0.0)?cout<<"Not yet completed Engineering"<<endl:cout<<"Done with Engineering"<<endl;

return 0;
}
Last edited on
Topic archived. No new replies allowed.