I am building a simple program that finds the average of three grades. The program runs fine. But, I am trying get my answer stored in fixed point notation with two decimal points of precision. Thus far, I have tried to using the: cout << setprecision(2); code. But, I have not been successful.
// This program finds the average of three grades
#include <iostream>
#include <iomanip>
#include <cmath>
#include <limits>
usingnamespace std;
int main()
{
float gradeOne;
float gradeTwo;
float gradeThree;
float average;
// Prompts the user for grades
cout << "Please input the first grade: ";
cin >> gradeOne;
cout << "\n";
cout << "Please input the second grade: ";
cin >> gradeTwo;
cout << "\n";
cout << "Please input the third grade: ";
cin >> gradeThree;
cout << "\n";
// Finds the average and displays the result
average = (gradeOne + gradeTwo + gradeThree) / 3;
cout << "So your average is " << average << endl;
cout << endl;
system ("pause");
return 0;
}