what error i did??
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#include<iostream>
#include<iomanip>
using namespace std;
void getdata();
void grade();
const int sentinel = 1000;
int i;
float rslt;
struct student
{
int snum;
float exam;
float quiz;
float progass;
float labex;
float test;
};
struct student result[sentinel];
int main()
{
char a;
do
{
getdata();
grade();
cout << "Press (Y/y) to continue: ";
cin >> a;
}while ( a == 'Y' || a == 'y' );
cout << setiosflags(ios::left);
for(i = 0; i <= count; i++) <==== here~!!!!!!!!
cout << setw(7) << result[i].snum
<< setw(3) << result[i].exam
<< setw(3) << result[i].quiz
<< setw(3) << result[i].progass
<< setw(3) << result[i].labex
<< setw(3) << result[i].test
<< endl;
system("pause");
return 0;
}
void getdata()
{
int count = 0;
cout << "Student Number: ";
cin >> result[i].snum;
cout << "=========================================" << endl;
cout << "Marks for exam is ";
cin >> result[i].exam;
result[i].exam = (( result[i].exam / 100 ) * 60 );
cout << "Marks for quiz is ";
cin >> result[i].quiz;
result[i].quiz = (( result[i].quiz / 100 ) * 10 );
cout << "Marks for programming assignment is ";
cin >> result[i].progass;
result[i].progass = (( result[i].progass / 100 ) * 10 );
cout << "Marks for lab exercise is ";
cin >> result[i].labex;
result[i].labex = (( result[i].labex / 100 ) * 10 );
cout << "Marks for test is ";
cin >> result[i].test;
result[i].test = (( result[i].test / 100 ) * 10 );
if ( result[i].exam > 100 || result[i].quiz > 100 || result[i].progass > 100 || result[i].labex > 100 || result[i].test > 100)
{
cout << "Marks must not more than 100\nPlease enter again\n" << endl;
return getdata();
}
else
{
rslt = result[i].exam + result[i].quiz + result[i].progass + result[i].labex + result[i].test;
count++;
}
}
void grade()
{
if (rslt >= 80.0 && rslt <= 100)
cout << "Final Score is " << rslt << "\nGrade is A " << endl;
else if (rslt >= 70 && rslt <= 79.9)
cout << "Final Score is " << rslt << "\nGrade is B " << endl;
else if (rslt >= 60 && rslt <= 69.9)
cout << "Final Score is " << rslt << "\nGrade is C " << endl;
else if (rslt >= 50 && rslt <= 59.9)
cout << "Final Score is " << rslt << "\nGrade is D " << endl;
else if (rslt >=0 && rslt <= 49.9)
cout << "Final Score is " << rslt << "\nGrade is F " << endl;
return;
}
|
can tell me what wrong i did?
There is no variable called 'count' in main().
oh yes thanks... i solved it.. thanks though.. btw can i ask how to assign a string to a variable???
You would need to #include <string>
first, then you can just do something like:
std::string my_string = "some string data";
ok thanks
Last edited on
Topic archived. No new replies allowed.