emergency call please... files ..ifstream!!

please anyone....

its an emergency here.. i`m stuck and my brain just stopped working :'C

so the question is a second part already did the first one!!

but now i`m stuck with trying my hardest to solve it...

if anyone can help??

Use the file created above as an input file. Write a program that takes the students’ data and store it in another file named “outtest.txt”. The program stores data in this sequence: name, total grade (after computing it). After storing all data in the output file, the program computes the average, max and min of the grades and stores them after student data in the output file.

Sample file output:
Ali 87
Saad 84.5
….
….
Average 76.4
MaxGrade 96
MinGrade 59.



and my unfinished code>>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;


void func (char name[] ,double mid1, double mid2,double finalex,double avg,double maxg, double ming, int k)
{
}


int main()
{

	ifstream myf("test.txt",ios::in);

	if (!myf)
	{
		cerr<<"file could not be opened" <<endl;
		exit(1);
	}

	double mid1;
	double mid2;
	double finalex;
	char name[30];
	double avg, maxg, ming;
	int k=0;


	
	while(myf>>name>>mid1>>mid2>>finalex)
	{
		k++;
		func (name , mid1, mid2, finalex, avg, maxg,ming,k);
	}


	myf.close();



	return 0;
}
But what do you think, func has to do? Even not its name will reflect your Intention.
tcs


i`m really mind closed this moment ...
""dying mentally""

i really respect computer engineers, and programmers for being able of enduring such things!! :D

but me... i`ll enter a coma eventually.._(_-_)_
please anyone ??? help

the perviouse program ..i`ve entered 4 names like this with their grades...

ali 45 66 38

saad 60 35 43.8

omar 49 33 35.5

abdullah 33 44 64
.......

and it`s a while loop.. and saves it in a file!!

i need to call it and take the sum for each student of their grades seperatley and get the average !!??


can anyone please help??
Last edited on
Advice:
-First do this without using functions.
-Storing data is the same as loading it, only you have to use ofstream and opperator <<

Calculating the results is a trivial thing, I hope you don't need help with that.
well.. actually my problem is the calculating part!!:c

iy`s not an array to do a loop for each student!!??
Try it and we can discuss your solution ;-)
You may use an outer loop for all students and an inner one for his/her grades.
Topic archived. No new replies allowed.