#include <iostream>
usingnamespace std;
int main()
{ // Begin Main Function
// Declare Variables, grade average and days absent
double grade;
int days;
// Input Items, grade average and days absent
cout<<"What is your course grade average? ";
cin>>grade;
cout<<"How many days were you absent? ";
cin>>days;
if(grade < 91)
{
if(grade < 93)
{
cout << "Don't take final." << endl;
}
else
{
cout << "Take final." << endl;
} // End of < 91
}
else
{
cout << "Golden." << endl;
}
system ("PAUSE");
return 0;
} // End Main Function
Well basically you only need an "if else" statement and then continue the code. I don't like how he has drawn his flowchart, no arrows makes it a tad vague to go through, have to follow the entire line.
1) You'll likely have to initialize a third variable to track the need to take the final. You can use char exempt; or bool exempt = true;
This way, instead of running a "cout << "Don't take final"" or "cout << "take final"", you can use a final
1 2 3 4
if(exempt = false) // false means student is not exempt from test
cout << "take final" << endl;
else
cout << "don't take final" << endl;
2) Your first if statement checks to see if grade is less than 91, and then it immediately checks to see if grade is less than 93. If it checks true that grade is less than 91, it'll automatically check true that grade is less than 93, so you'll need to adjust that. Perhaps try this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
if(grade < 91)
exempt = false;
else // meaning grade is not less than 91
{
if(grade < 93)
{
if(days > 1) // more than one day missed
exempt = false;
else // days missed is equal to or less than one
exempt = true;
} // end if grade is less than 93
else // grade is equal to or greater than 93
if(days > 3)
exempt = false;
else // days missed is equal to or less than two
exempt = true;
} // end else grade not less than 91
Then go back and add the code I listed earlier or something similar to it to say if they need to take the test or not.
I hope this works at least. I'm new to C++ myself, but I think this would work.
#include <iostream>
usingnamespace std;
int main()
{ // Begin Main Function
// Declare Variables, bill, tip, total
double grade;
int days;
char exempt;
// Input Items, grade average and days absent
cout<<"What is your course grade average? ";
cin>>grade;
cout<<"How many days were you absent? ";
cin>>days;
if(grade < 91)
exempt = false;
else // meaning grade is not less than 91
{
if(grade < 93)
{
if(days > 1) // more than one day missed
exempt = false;
else // days missed is equal to or less than one
exempt = true;
} // end if grade is less than 93
else // grade is equal to or greater than 93
if(days > 3)
exempt = false;
else // days missed is equal to or less than two
exempt = true;
} // end else grade not less than 91
if(exempt = false) // false means student is not exempt from test
cout << "take final" << endl;
else
cout << "don't take final" << endl;
system ("PAUSE");
return 0;
} // End Main Function