Hey, this is the task I have to do

http://faculty.winthrop.edu/olsena/CSCI%20207/c207p6CalcAveClasses-s12.pdf

I'm trying to read each part..I have to read in the ID, exam, test grades, program grades, and lab test/quiz grades. In the insructions, it says I have to set methods for each one which I did. Now i'm having a problem reading the test grades together, then the program grades together, then the lab test grades together.

This is my input code

``````1547436 70 81 90 57 98 92 80 50 94 80 100 100 0 -9 -9
1478732 82 81 82 86 98 92 100 90 92 100 100 100 100 -9 -9
1327835 56 78 64 59 96 94 96 76 95 50 100 100 73 -9 -9
1426531 67 80 73 81 100 100 88 80 92 70 100 100 100 -9 -9
1250737 40 68 55 40 0 92 100 70 50 70 100 78 78 -9 -9
1140605 49 61 74 49 98 100 70 100 80 50 100 100 80 -9 -9
1128743 61 87 58 73 100 100 80 80 90 100 100 100 100 -9 -9
1250807 96 96 93 96 100 100 100 100 100 100 100 100 100 -9 -9
1227542 90 90 96 95 100 100 100 100 100 100 100 100 100 -9 -9
1250357 100 96 96 97 100 92 100 100 100 100 100 100 100 -9 -9
1123288 92 85 67 88 98 100 100 86 90 30 30 30 30 -9 -9
``````

I put the -9's there as sentinel values if that's right.

Anyways, this is the code I have so far. Please help me in the right direction with reading these values in correctly. That way I can focus on getting the averages for each one. Thank you. You see, I tried to do while(g.setLabquiz >=0) but it won't accept the g.setLabquiz. Much help please

``````#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <stdlib.h>
using namespace std;

{
private:
int ID;
int exam;
double test;
double program;
double labquiz;
double cg;

public:
void setData(ifstream &);
void setID(ifstream & );
void setExam(ifstream &);
void setLabquiz(ifstream &);
void setTest(ifstream &);
void setProg(ifstream &);
{return cg;}
void printResults(ofstream &OutputFile);
};

{
infile>>ID;
return;
}

{
infile>>exam;
return;
}

{
infile>>labquiz>>labquiz>>labquiz>>labquiz>>labquiz;
return;
}
{
infile>>test>>test>>test;
return;
}
{
infile>>program>>program>>program>>program;
return;
}

{

return;
}

{
return;
}

//Function Prototypes Go Here

int main()
{

ofstream OutputFile;
OutputFile.open("Output.dat");

ifstream infile;
infile.open("Input.dat");
OutputFile<<fixed<<showpoint<<setprecision(1)<<endl;

g.setID(infile);
g.setExam(infile);
while(!infile.eof())
{
g.setLabquiz(infile);
g.setProg(infile);
g.setTest(infile);
while(g.setLabquiz >=0)
{

g.setLabquiz(infile);
g.setProg(infile);
g.setTest(infile);
}
g.printResults(OutputFile);
g.setID(infile);
g.setExam(infile);
}

OutputFile.close();
infile.close();
return 0;
}
//Function Definitions Go Here
{
OutputFile<<setw(30)<<"Thomas Powe"<<endl;
OutputFile<<setw(29)<<"04-12-12"<<endl<<endl;
return;
}

{

return;
}
{
return;
}
{

return;
}
``````
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Tommeh

I put the -9's there as sentinel values if that's right.

I don't think you need that. The instructions states the exact number of grades in each category, so all your program has to do is read that quantity of numbers. No need for a sentinel value.

setProg() -- you need to read each of the grades in individual variables so that the function can later make calculations. It can't do that when you read all the grades into the same variable. Same goes for the other set functions.

Edited by Ancient Dragon

so for example, I'll havee to read the program grades in like this???

infile>>program1>>program2>>program3>>program4;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.