473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

C ++ programming here my codes

# 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
2 1084
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Ken | last post by:
Hi. Can anyone refer me to any articles about the compatibility between c++ polymorphism and real-time programming? I'm currently on a real-time c++ project, and we're having a discussion...
0
by: Author Tarun Tyagi | last post by:
Hi! I am glad to introduce World's First Book on Professional Data Recovery Programming. Book also Includes a FREE CD, which contains complete Source Codes of all the software/Programs described...
0
by: Author Tarun Tyagi | last post by:
Hi! I am glad to introduce World's First Book on Professional Data Recovery Programming. Book also Includes a FREE CD, which contains complete Source Codes of all the software/Programs described...
2
by: belial | last post by:
Hi! I am new on the group and join in as i am in bad need of help in C programming.I'm a fresher and got to tackle the basics of C in the next few months,so i wonder if anyone on that group could...
42
by: Kevin Spencer | last post by:
Is it just me, or am I really observing a trend away from analysis and probem-solving amongst programmers? Let me be more specific: It seems that every day, in greater numbers, people are coming...
9
by: Smithers | last post by:
Please consider this humble method: public void ResetCounters() { m_TotalExceptionsDetected = 0; m_TotalMessagesSent = 0; } Given no further information, would you wrap those two lines in a...
270
by: jacob navia | last post by:
In my "Happy Christmas" message, I proposed a function to read a file into a RAM buffer and return that buffer or NULL if the file doesn't exist or some other error is found. It is interesting...
53
by: Vicent Giner | last post by:
Hello. I am new to Python. It seems a very interesting language to me. Its simplicity is very attractive. However, it is usually said that Python is not a compiled but interpreted programming...
0
by: smartx | last post by:
New sample codes, direct x game programming at: http://gptutors.com With best wishes, smartx.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.