Write a function qualityPoints that inputs a student’s average and returns 4 if a student’s average is 90–100, 3 if the average is 80–89, 2 if the average is 70–79, 1 if the average is 60–69 and 0 if the average is lower than 60.

What will be an ideal response?

```
// Determine quality points on 0 to 4 scale
// for averages in 0 to 100 range.
#include
using namespace std;

int qualityPoints( int ); // function prototype

int main()
{
int average; // current average

// loop for 5 inputs
for ( int loop = 1; loop <= 5; loop++ )
{
cout << "\nEnter the student's average: ";
cin >> average;

// determine and display corresponding quality points
cout << average << " on a 4 point scale is "
<< qualityPoints( average ) << endl;
} // end for

cout << endl;
} // end main

// qualityPoints takes average in range 0 to 100 and
// returns corresponding quality points on 0 to 4 scale
int qualityPoints( int average )
{
if ( average >= 90 ) // 90 <= average <= 100
return 4;
else if ( average >= 80 ) // 80 <= average <= 89
return 3;
else if ( average >= 70 ) // 70 <= average <= 79
return 2;
else if ( average >= 60 ) // 60 <= average <= 69
return 1;
else // 0 <= average < 60
return 0;
} // end function qualityPoints
```

Computer Science & Information Technology

You might also like to view...

What is the benefit of adding graphics and media objects to a PowerPoint presentation?

What will be an ideal response?

Computer Science & Information Technology

In other programming languages, such as C++, abstract classes are known as ____ classes.

A. anonymous B. pseudo C. simulated D. virtual

Computer Science & Information Technology