Print Friendly and PDF
(Quality Points for Numeric Grades) 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. Solution:
(Quality Points for Numeric Grades) Write a function quality Points 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.

Solution:
 
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
 
int qualityPoints(int);
 
int main()
{
   int average;
 
   cout << "Enter student's average (between 0 and 100): ";
   cin >> average;
 
   while(average < 0 || average > 100)
   {
      cout << "Enter correct student's average value (between 0 and 100): ";
      cin >> average;
   }
   cout << qualityPoints(average);
 
   return 0;
}
 
int qualityPoints(int average)
{
   if(average >= 90)
      return 4;
   else if( average >= 80)
      return 3;
   else if(average >= 70)
      return 2;
   else if(average >= 60)
      return 1;
   else
      return 0;
}
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: