rendered paste body//p6.cxx//************************************************************************************//AUTHOR:Aaron Sopfe////COUSE TITLE: Programming 1////COUSE NUMBER: CS116////PROF NAME: Moe Bidgoli////ASSIGMENT NUMBER #6////DUE DATE OCT-17-2011////POSSIBLE POINTS ? Points////PURPOSE//// This program uses an input file to collect name, id, and three exam scores// (exam1, exam2, exam3) in to an output file, it checks to make sure the student// ID, and exams are in set define range and will display an error if the value(s)// are not in the range. The program also averages the exam grades and does another// check to make sure the average does not supass 100 or under 0. The final part of// the program will display pass or fail if the average is above or below 70.// This program uses a loop so more then one record can be processed in a single// running of the program.////**********************************************************************************#include <iomanip>#include <fstream>#include <iostream>using namespace std;const float MAXE = 100.00; //max exam scoreconst float MINE = 0.00; //min exam scoreconst int MAXID = 9999; //max studIdconst int MINID = 1111; //min studIdconst float EXMIN = 70.00; //min passing examfloat sumexam; //sums of examsfloat perPass; // percent passed with avgerage of 70 or morefloat perFail; // percent failed wtih averge less then 70int main(){ ofstream outFile; ifstream inFile; outFile.open("out.data"); inFile.open("in.data"); outFile.setf(ios::fixed); outFile.precision(2); string studName, pass, fail, inv, work; // inv = invalid work = either pass, fail, or inv int studId; //student id float exam1, exam2, exam3, avg, mavg; //mavg == class mean avg, avg = average int invRd = 0; //invalid record int validRd = 0; //Valid record int noPass = 0; //number of passing int noFail = 0; //Number of failing //float perpass; //percent pass //float perfail; //percent fail pass = "PASSED"; fail = "FAILED"; inv = "~ INVALID DATA ~"; outFile << "~~ < Student Exam Report > ~~" << endl; outFile << "Student ID:" << setw(11) << "Name" << setw(11) << "Exam 1" << setw(11) << "Exam 2" << setw(11) << "Exam 3" << setw(11) << "Average" << setw(20) << "Passed/Failed" << endl; outFile << "-----------" << setw(11) << "----" << setw(11) << "------" << setw(11) << "------" << setw(11) << "------" << setw(11) << "-------" << setw(20) << "-------------" << endl; inFile >> studName >> studId >> exam1 >> exam2 >> exam3; while(inFile) { avg = ( exam1 + exam2 + exam3 )/3; if( avg >= MINE && avg <= MAXE && exam1 >= MINE && exam1 <= MAXE && exam2 >= MINE && exam2 <= MAXE && exam3 >= MINE && exam3 <= MAXE && studId >= MINID && studId <= MAXID ) //then { sumexam = sumexam + avg; validRd = validRd + 1; outFile << studId << setw(11) << studName << setw(11) << exam1 << setw(11) << exam2 << setw(11) << exam3 << setw(11); if( avg >= EXMIN && avg <= MAXE) //then { noPass = noPass + 1; outFile << avg << setw(20) <<pass << endl; } else if( avg < EXMIN ) { //then noFail = noFail + 1; outFile << avg << setw(20) << fail << endl; } } else { invRd = invRd + 1; outFile << studId << setw(11) << studName << setw(11) << exam1 << setw(11) << exam2 << setw(11) << exam3 << setw(11) << inv << setw(20) << " " << endl; } inFile >> studName >> studId >> exam1 >> exam2 >> exam3; } if (validRd != 0) //then { perPass = (noPass / validRd) * 100; perFail = (noFail / validRd) * 100; mavg = (sumexam / validRd); outFile << endl <<"Mean AVG of exams = " << mavg << endl << endl; outFile << "Invalid data: " << invRd << endl; outFile << "Valid data: " << validRd << endl << endl; outFile << "% Passed " << perPass << endl; outFile << "% Failed " << perFail << endl; outFile << "*< end >*" << endl; } else { outFile << "Error: Can not divide by zero" << endl; } inFile.close(); outFile.close(); return 0;}//in.data Lewis,Rose 1111 75.00 80 70Weber,Mark 7821 70 69 69Runer,Jon 9102 88 88.00 91Sooner,Ali 8888 -1 0 100