adasdasdasdaasd

Yes, just ask multiple times and you will get much more help xD

The return type of main should be int.
you mean change void grading to int grading?
No I mean change void main to int main.
its gives me this:
1>c:\users\jayson\desktop\lab project\lab project.cpp(114): warning C4305: '=' : truncation from 'int' to 'char'
1>c:\users\jayson\desktop\lab project\lab project.cpp(114): warning C4309: '=' : truncation of constant value.

and it crash
OP:
Can anyone take a look at this assignment. How to change A to A+,B to A, C to A-,etc.

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>

using namespace std;
const int quizes = 6;

void heading();
void printdata(int&,int,string,string);
void avgGrd(int,int,int,int,int,double&,char&);
void avgSc(int,int,int,int,int,double&);
void highlow(int,int,int,int,int&,int&);
void grading(double,char&);
void avgQ(double,double&,int&);
void printStudentQuiz(int);


void main()
{
ifstream data;
string filename, Lname, Fname;
int id, q1, q2, q3, q4, final, no = 1;
int countq1 = 0,countq2 = 0,countq3 = 0,countq4 = 0, countf = 0, countavg = 0;
double Tq1 = 0, Tq2= 0, Tq3= 0, Tq4= 0, Tfinal= 0, Tavg= 0;
double avgscore;
char grd;

cout << "Enter the file name: "; cin >> filename;
filename += ".txt";
data.open(filename.c_str());
heading();
data.ignore(80, '\n');
data >> id >> Lname >> Fname >> q1 >> q2 >> q3 >> q4 >> final;

while (!data.eof())
{
printdata(no,id,Lname,Fname);
avgGrd(q1,q2,q3,q4,final,avgscore,grd);
avgQ(q1,Tq1,countq1);
avgQ(q2,Tq2,countq2);
avgQ(q3,Tq3,countq3);
avgQ(q4,Tq4,countq4);
avgQ(final,Tfinal,countf);
avgQ(avgscore,Tavg,countavg);
data >> id >> Lname >> Fname >> q1 >> q2 >> q3 >> q4 >> final;

}
cout << setw(75) << "----------------------------------------" << endl;
cout << setw(43) << Tq1/countq1 << setw(6) << Tq2/countq2
<< setw(6) << Tq3/countq3 << setw(6) << Tq4/countq4 << setw(6)
<< Tfinal/countf << setw(6) << Tavg/countavg << endl << endl;
data.close();

}

void heading()
{
cout << endl << " Fall 2011 Studen Grade report: " << endl << endl;
cout << left << setw(4) << "No." << setw(8) << "ID" << setw(14) << "Last Name"
<< setw(13) << "First Name" << setw(6) << "Quiz1" << setw(6) << "Quiz2"
<< setw(6) << "Quiz3" << setw(6) << "Quiz4" << setw(7) << "Final"
<< setw(5) << "Avg" << setw(2) << "Grd" << endl;
cout << "------------------------------------------------"
<< "-------------------------------" << endl;
}

void printdata(int& no,int id,string ln,string fn)
{
cout << left << setw(4) << no << setw(8) << id << setw(14)
<< ln << setw(13) << fn << setw(3);
no++;
}

void avgGrd(int q1, int q2, int q3, int q4, int final, double& avg, char& grd)
{
avgSc(q1,q2,q3,q4,final,avg);
grading(avg,grd);
cout << right;
printStudentQuiz(q1);
printStudentQuiz(q2);
printStudentQuiz(q3);
printStudentQuiz(q4);
cout << final << setw(7) << avg << setw(3)<< grd << endl;
}

void avgSc(int q1, int q2, int q3, int q4, int final, double& avg)
{
int highest, lowest;
highlow(q1,q2,q3,q4,highest,lowest);
cout << fixed << setprecision(1);
avg = double(q1+q2+q3+q4+final*2+highest-lowest)/quizes;
}

void highlow(int q1,int q2,int q3,int q4,int& high,int& low)
{
high = q1;
if(q2>high) { high = q2; }
if(q3>high) { high = q3; }
if(q4>high) { high = q4; }

low = q1;
if(q2<low) { low = q2; }
if(q3<low) { low = q3; }
if(q4<low) { low = q4; }
}

void grading(double avg, char& grd)
{
if (avg>96.3)
grd = 'A';
else if (avg>=80)
grd = 'B';
else if (avg>=70)
grd = 'C';
else if (avg>=60)
grd = 'D';
else
grd = 'F';
}

void avgQ(double q,double& Total,int& count)
{
Total += q;
if (q != 0)
{
count++;
}
}
void printStudentQuiz(int quiz)
{
if (quiz == 0)
cout << ' ';
else
cout << quiz;
cout << setw(6);
}
can u ?
Can I what? What line is line 114 and when does the crash occur?
i try change what you told me, change void main to int main but is not working
my point is to change A to A+ , B to A, C to A- , can u do that for me?
line 114 is :
if (avg>96.3)
grd = 'A';
If you want more than one char use a string. Change grd to a string.

1
2
string grd;
grd = "A+"; // note that we use double quotes for strings  
thanks, let me try it first
not working, when i change void grading to string grading , the red line pops up under equal sign.

string grading(double avg, char& grd)
{
if (avg>96.3)
grd = "A+";


the red line pops up under equal sign.

If that's what you're relying on to write good code, C++ is not for you.

Why are we even still answering this thread? He deleted his original post after we helped him, and then came back when he realised that he actually still didn't understand.
Last edited on
i am just trying to get my homework done, thats why i m here, if you dont want to help , you can get out of this page.
if you dont want to help , you can get out of this page.


If you want help, don't delete your posts.

Your question was in your first post and in the subject line of this thread. Tell me, how do you expect people to answer your question when you've deleted it?
because im afriad others people from my class who is doing the same assigment going to copy it.
Sorry to bump this again, but please stop bumping his posts...it's getting on my nerves...you obviously don't know how to use a forum so go find a tutorial or even better look at your notes...or even better then that go ask your teacher..
Topic archived. No new replies allowed.