Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This program works great, but I am needing to get the input file information and

ID: 3627453 • Letter: T

Question

This program works great, but I am needing to get the input file information and print it directly to the output file. Here I have the input file info, then the program, and then what the output file should look like. The yellow portion is what I am having an issue with. This info is pulled directly from the input file.
This is in the input file
f 3.40
f 4.00
m 3.56
m 3.80
f 2.30
f 3.95
m 3.90
m 4.00
m 2.00
f 4.00
f 2.80
m 3.70
m 2.98
f 3.89
m 4.00
f 3.90
m 1.90
m 2.90
f 1.50
f 2.67
m 3.80
m 2.35
f 2.90
f 3.70
f 4.00
m 3.78
m 4.00
f 3.98


-------------------------------------------------------------------
#include
#include
using namespace std;

//Variables
int countMale, countFemale;
float sumMaleGPA, sumFemaleGPA;
float avgMaleGPA, avgFemaleGPA;

//Open input and output files
void openFiles (ifstream &inFile, ofstream &outFile)

{
//Get information from input file
inFile.open ("Ch7_Ex6Data.txt");
if (inFile.fail())
{
cout <<"Can not find the file input.txt";
cout <<"Exiting the program...";
system ("pause");
exit(0);
}

//Opens the output file
outFile.open ("Ch7_Ex6out.txt");

//Set precision
outFile.setf(ios::fixed,ios::floatfield);
outFile.precision (2);
//Output to console
cout.setf(ios::fixed,ios::floatfield);
cout.precision(2);

}
void initialize()//Initializing Variables
{
countMale=0;
countFemale=0;
sumMaleGPA=0.0;
sumFemaleGPA=0.0;
avgMaleGPA=0.0;
avgFemaleGPA=0.0;
}
//Sum of the student grades
void sumGrades (ifstream &inFile)
{
char gender;
double gpa;
while (!inFile.eof())

{
inFile>>gender;

inFile>>gpa;
if(gender=='M'||gender=='m')

{
sumMaleGPA += gpa;
countMale++;
}
else
{

//Initialize Variables
sumFemaleGPA += gpa;
countFemale++;
}
}

//Close input file
inFile.close();
}
//Find average student grades
void averageGrade()
{
avgMaleGPA=sumMaleGPA/countMale;
avgFemaleGPA=sumFemaleGPA/countFemale;
}
//Print

void printResults(ofstream &outFile)
{
outFile<<"Sum female GPA = "< cout<<"Sum female GPA = "< outFile<<"Sum male GPA = "< cout<<"Sum male GPA = "< outFile<<"Female count = "< cout<<"Female count = "< outFile<<"Male count = "< cout<<"Male count = "< outFile<<"Average female GPA = "< cout<<"Average female GPA = "< outFile<<"Average male GPA = "< cout<<"Average male GPA = "<



//Close output file
outFile.close ();
}
int main()
{
//input file
ifstream inFile;
//output file
ofstream outFile;

//Calls
openFiles(inFile,outFile);
initialize();
sumGrades(inFile);
averageGrade();
printResults(outFile);
system ("pause");
return 0;
}
----------------------------------------------------------
This is what the output file should look like
Processing grades.
f 3.40
f 4.00
m 3.56
m 3.80
f 2.30
f 3.95
m 3.90
m 4.00
m 2.00
f 4.00
f 2.80
m 3.70
m 2.98
f 3.89
m 4.00
f 3.90
m 1.90
m 2.90
f 1.50
f 2.67
m 3.80
m 2.35
f 2.90
f 3.70
f 4.00
m 3.78
m 4.00
f 3.98
Sum female GPA =
Sum male GPA =
Female count =
Male count =
Average female GPA =
Average male GPA =

Explanation / Answer

DEAR FRIEND this is the program u want and modified the code PLEASE RATE #include #include using namespace std; //Variables int countMale, countFemale; float sumMaleGPA, sumFemaleGPA; float avgMaleGPA, avgFemaleGPA; //Open input and output files void openFiles (ifstream &inFile, ofstream &outFile) { //Get information from input file inFile.open ("Ch7_Ex6Data.txt"); if (inFile.fail()) { cout gpa; if(gender=='M'||gender=='m') { sumMaleGPA += gpa; countMale++; } else { //Initialize Variables sumFemaleGPA += gpa; countFemale++; } } //Close input file inFile.close(); } //Find average student grades void averageGrade() { avgMaleGPA=sumMaleGPA/countMale; avgFemaleGPA=sumFemaleGPA/countFemale; } //Print void printResults(ofstream &outFile) { ifstream infile; infile.open("Ch7_Ex6Data.txt"); double N; char ch; while(!infile.eof()) { infile>>ch>>N; outFile
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote