PLEASE FOLLOW THE INSTRUCTION CAREFULLY ! DO NOT WIRTE THE CODE ON A PAPER OR! I
ID: 3698830 • Letter: P
Question
PLEASE FOLLOW THE INSTRUCTION CAREFULLY ! DO NOT WIRTE THE CODE ON A PAPER OR! I NEED THE CODE THAT CAN RUN EXACTLY AS THE INSTRUCTION, ALSO NEED THE SCREENSHOT OF THE PROGRAM TOO! REMEMBER, WRITE THE CODE ON "MICROSOFT VISUAL STUDIO" C++, MY COMPUTER IS A PC NOT MACBOOK, PLEASE WRITE THE CODE THAT MY COMPUTER CAN ACTUALLY RUN!
ConsoleApplication42 . Microsoft Visual Studio File Edit View Project Build Debug Team Tools Test Analyze Window Help Debug ?11x86 ConsoleApplication42.cpp ? ?ConsoleApplication42 (Global Scope) EV/ ConsoleApplication42.cpp Defines the entry point for the console application #include "stdafx.h" ?int main() return e 100 %Explanation / Answer
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
string str;
float marks1,marks2,min=101,max=-1,sum=0,g;
char grade;
int count=0;
ifstream myReadFile;
myReadFile.open("Grade.txt");
if (myReadFile.is_open())
{
cout<<"Name "<<"TotalPoints"<<" Average"<<" Grade"<<endl;
while (!myReadFile.eof())
{
myReadFile >> str>>marks1>>marks2;
g=(marks1+marks2)/2;
if(g>=90)
grade='A';
else
if(g>=80)
grade='B';
else
if(g>=70)
grade='C';
else
if(g>=60)
grade='D';
else
grade='F';
sum=sum+g;
count++;
if(max<g)
max=g;
if(min>g)
min=g;
if(str.length()<6)
cout<<str<<" "<<(marks1+marks2)<<" "<<(marks1+marks2)/2<<" "<<grade<<" ";
else
cout<<str<<" "<<(marks1+marks2)<<" "<<(marks1+marks2)/2<<" "<<grade<<" ";
myReadFile.ignore();
}
}
myReadFile.close();
if(count>0)
sum=sum/count;
cout<<" Class Statistics: ";
cout<<"Number:"<<count<<endl;
cout<<"Average:"<<sum<<endl;
cout<<"Minimum:"<<min<<endl;
cout<<"Maximum:"<<max<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.