Trying to get decimal places in code

Trying to get grades in along with grades with 5 decimal places in. Having trouble with my loop. Not sure what I'm doing wrong. This is what I have so far.

#include <iostream>
#include <cmath>
#include <fstream>

using namespace std;

int main ()

{
//input variables
float NumberRight;
float TotalPoints;
float GradePercent;
float grade;
float Score;
float setprecision = (5);



ifstream inData;

// open file
inData.open ("grades.txt");

grade = ceil(Score) / TotalPoints)* 100;
cout << fixed << setprecision(5);


// read values
inData >> NumberRight >> TotalPoints;


//calculate values

GradePercent = NumberRight / TotalPoints;

cout << "You got an ";


if (GradePercent > 90)

cout << "Excellent" << endl;


if (GradePercent > 80)

cout << "Great work" << endl;

if (GradePercent > 70)

cout << "Could be better" << endl;

else if (GradePercent >= 60)

cout << "Needs Improvement" << endl;

else (GradePercent < 50)

cout << "Fail" << endl;


return 0;
}
#include<iomanip>
Still gave me errors.

error C2064: term does not evaluate to a function taking 1 arguments
error C2146: syntax error : missing ';' before identifier 'cout'
IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
IntelliSense: expected a ';'
http://www.cplusplus.com/reference/iomanip/setprecision/

So you need to find where you forgot the parentheses. Also, I believe you may need to remove the line float setprecision = (5)

You could also use printf.
Last edited on
Topic archived. No new replies allowed.