Undefined
By: jazy | Date: Dec 6 2006 19:33 | Format: C++ | Expires: never | Size: 2.19 KB | Hits: 1479
- #include <cstdlib>
- #include <iostream>
- #include <fstream>
- using namespace std;
- void getData(ifstream &infile,int grade [], int &sizeOf); //only one needed to reference since once we don't need to modify this
- void curveData(int curve[],int sizeOf,int grade[]);
- void printData(ofstream &outfile,int curve[],int grade[],int sizeOf);
- //void test(ifstream &infile) {infile.open("temp.cpp");};
- const int SIZE=15; //we are assuming that the size of 15 is the max for this
- double myMax=0.0;
- int main()
- {
- // Variables going to be used by main //
- ifstream infile;
- ofstream outfile;
- int i;
- int grade[SIZE];
- int curve[SIZE];
- getData(infile,grade,i);
- i -= 1; // it will be plus one more then in file. due to while struct.
- curveData(curve,i,grade);
- printData(outfile,curve,grade,i);
- //Close the files that have been used in and out
- infile.close();
- outfile.close();
- return 0;
- }
- void getData(ifstream &infile,int grade[],int &sizeOf) {
- //open input file
- infile.open("indata7.txt");
- //since the size if unknown we will set it to '0' until we know after reading the input the size
- sizeOf=0;
- while (!infile.eof()) {
- infile >> grade[sizeOf];
- //Since we need to find the max no need to transverse this array again we can do it in one step.
- //lets make sure we don't get any garbage values anything > 100;
- if (grade[sizeOf] >= myMax && grade[sizeOf] <= 100)
- myMax = grade[sizeOf];.
- //since there was an element we will increase the known size
- sizeOf++;
- }
- }
- void curveData(int curve[],int sizeOf,int grade[]) {
- // since we know myMax we can just do this here and mult each element for the curved grade.
- double mult = 100.0/myMax;
- for (int k=0;k<sizeOf;k++) {
- curve[k] = grade[k] * mult; //save info in a new array to output both of them.
- }
- }
- void printData(ofstream &outfile,int curve[],int grade[],int sizeOf) {
- //open the outputfile that is going to be used
- outfile.open("outdata7.txt");
- outfile<<"Actual GradesttCurved Gradesn";
- for(int j = 0;j < sizeOf; j++)
- outfile<<grade[j]<<"ttt"<<curve[j]<<endl; //output both actual and curved grades.
- }
Latest pastes
1 days ago
2 days ago
5 days ago
6 days ago
6 days ago