By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,851 Members | 2,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,851 IT Pros & Developers. It's quick & easy.

C ++ programming here my codes

P: n/a
# include <iostream>

using std::cout;
using std::cin;
using std::endl;

enum GradeType {A, B, C, D, F};
struct StudentRec
{

string firstName;
string lastName;
float average;
int grade;
int finalExam;
GradeType courseGrade;
};
int main
{
StudentRec FirstStudent;
StudentRec student;
int grade
cout << " Enter your First Name:" << endl;
cin >> firstName;

cout << "Enter your percentage:" << endl;
cin >>percentage;

cout << " name " << " score " << " Final Grade " << endl;

cin >> student.finalExam;
grade = student.finalExam + studentGrade;

if (grade >=90)
student.courseGrade = A;
else if (grade >=80)
student.courseGrade = B;

else if (grade >= 70)
student.courseGrade = D;

else if (grade>= 60)
student.courseGrade = C;

else

cout << grade << "F" << endl;
return 0;
}

I am sorry, I forget to write my codes. But it does not work.

Sandra

Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Please write postings that belong to other postings as replies to those
postings. It's rather cumbersome to find out what you're talking about.
sscolon wrote:
# include <iostream>

using std::cout;
using std::cin;
using std::endl;

enum GradeType {A, B, C, D, F};
struct StudentRec
{

string firstName;
string lastName;
float average;
int grade;
int finalExam;
GradeType courseGrade;
};
int main
{
StudentRec FirstStudent;
StudentRec student;
int grade
cout << " Enter your First Name:" << endl;
cin >> firstName;

cout << "Enter your percentage:" << endl;
cin >>percentage;

cout << " name " << " score " << " Final Grade " << endl;

cin >> student.finalExam;
grade = student.finalExam + studentGrade;

if (grade >=90)
student.courseGrade = A;
else if (grade >=80)
student.courseGrade = B;

else if (grade >= 70)
student.courseGrade = D;

else if (grade>= 60)
student.courseGrade = C;

else

cout << grade << "F" << endl;
return 0;
}

I am sorry, I forget to write my codes. But it does not work.


"does not work" isn't a very good description. How does it not work?
Doesn't it do what you expected? What does it do instead? Does it not
compile or link? What error message did you get? In which line?

Jul 22 '05 #2

P: n/a
"sscolon" <ss*********@yahoo.com> wrote in message
news:d6******************************@localhost.ta lkaboutprogramming.com...

You didn't say what's wrong or what help you want, so I'm just guessing that you want to know
what's wrong with your code.
# include <iostream>
Also:
#include <string>
using std::cout;
using std::cin;
using std::endl;
Also:
using std::string;

enum GradeType {A, B, C, D, F};
struct StudentRec
{

string firstName;
string lastName;
float average;
int grade;
int finalExam;
GradeType courseGrade;
};
int main
Should be: int main()
{
StudentRec FirstStudent;
You are not using FirstStudent anywhere.
StudentRec student;
int grade
Should be: int grade;


cout << " Enter your First Name:" << endl;
cin >> firstName;
You have not defined a variable 'firstName'. Did you mean student.firstName?

cout << "Enter your percentage:" << endl;
cin >>percentage;
You have not defined a variable 'percentage'. All variables you use have to be defined somewhere
first.

cout << " name " << " score " << " Final Grade " << endl;

cin >> student.finalExam;
grade = student.finalExam + studentGrade;
You have not defined a variable 'studentGrade'.

if (grade >=90)
student.courseGrade = A;
else if (grade >=80)
student.courseGrade = B;

else if (grade >= 70)
student.courseGrade = D;

else if (grade>= 60)
student.courseGrade = C;

else

cout << grade << "F" << endl;
return 0;
}


Also, to make it work as you described earlier, you will need a collection of StudentRecs (e.g.,
a std::vector<StudentRec>) and you will need a loop in your code (a 'do' or a 'while') so that
the program will keep asking for details of more students until the exit value is entered. But
you can add that later. Get the code working for one student first.

If you have more questions, reply to a post in this thread instead of starting a new one. All
posts relating to the same problem should be together.

DW

Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.