Help Writing Program From Flow Chart

I need help creating a program based on the following flowchart:
http://dublee.com/prog/examgradecheck.jpg

I put the following code together but I am not able to incorporate the absent days into the program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace 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 


Any help would be greatly appreciated. Thanks!
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.

Add exempt_on_final variable, you're on track.
Last edited on
Few things:

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.
I made the suggested edits to the code. It makes a lot more sense now however, no matter what I input, it always says don't take final...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
using namespace 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 


Thank you for helping! Really appreciate it!
Fixed it! It should be if(exempt == false)
Thanks!
That's right. Good catch. I'm learning, too, so you taught me something as well! :-)
Topic archived. No new replies allowed.