can someone help me write this program please ...

Write a program to read in a series of characters representing student's grades from a file called "grades.txt" until the first blank space is reached. Echo and print the input data, one character per line. If the grade is A, B, C, or D, it is a passing grade. If it is F, it is a failing grade. Any other character will produce an error message.

The program must count how many passing grades, how many failing grades and how many errors were found. At the end of the program, print all the counts. YOU MUST USE function(s) to solve the program, such as a function to get and print the input data, and a function to check whether the grade is pass of fail or error.

For example: if the file contained
AFBDFXC XABCYZ
the program should report:

there were 4 passes, 2 failure and 1 error.

Remember, it must stop at the blank! You need to use the get function to read the blank.

#include<iostream>
#include<fstream>
using namespace std;
int main()
{
isftream infile;
infile.open("grades.txt");
<Your calling fundtions code goes here>
return 0;

Last edited on
Damn I be pissed if i got an X,Y, or a Z for a grade.
Last edited on
We wont write your homework for you. Write the code and when you come across problems then ask us, we would be glad to help.
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <fstream>

int main()
{
   ifstream infile;
   infile.open("grades.txt");
   <No, YOUR code goes here>
   return 0;
}
I have to turn it in class, I didn't have time to write the code for it.

IF you want to help, then help,

if you don't want to help me then just don't say anything.
I feel almost obligated to say something. Do you have any idea how many people come on this site asking people to do their homework for them?

If you don't have time then that's probably your own fault. If it's not your fault and due to unforeseen circumstances, then your teachers would have likely granted an extension.

If you want the help then I'll help.

If you don't want the help, don't bother posting.
Last edited on
Damn I be pissed if i got an X,Y, or a Z for a grade.


lol.
ALRIGHT.
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
46
47
48
49
50
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
#define PROMPT cout << "<Press ENTER KEY to continue>";
#define PAUSE cin.ignore(numeric_limits<streamsize>::max(), '\n' );
void print(int pass, int fail , int error);
int main()
{
ifstream infile;
infile.open("grades.txt");
int failure=0;
int error=0;
int pass=0;
string stemp="-";

while(!infile.eof())
{
	infile>>stemp;
	for (int i = 0 ; i < stemp.length();i++)
	{
		stemp.at(i);
		if(stemp.at(i) =='A')
			pass++;
		else if(stemp.at(i) =='B')
			pass++;
		else if(stemp.at(i) =='C')
			pass++;
		else if(stemp.at(i)=='D')
			pass++;
		else if(stemp.at(i) =='F')
			failure++;
		else
			error++;
	}
	print(pass,failure,error);
	PROMPT;
	PAUSE;

}
return 0;
}

void print(int pass, int fail , int error)
{

	cout<<"Pass : "<<pass <<" Fail : "<<fail <<" Error : "<<error<<endl;
}

thx so much subzero, I understand what you are trying to say.

I didn't know how many people came to the site

thx
Topic archived. No new replies allowed.