| | |
correct my algorithm for average problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2006
Posts: 8
Reputation:
Solved Threads: 0
Hi all,
I just joined the post. Iam new to C programming. I have a question regarding a problem i found in some book. The problem is i have a input file with student ID, 5 program scores, midterm and final score. i have to check for wrong input of data(negative score),calculate average score for program,calculate student totalscore (30% of programming,30% midterm,35%final and 5%free for whoever takes final exam),give grade to student and then finally compute calss total score.
print in a format (sID,sc1,sc2,sc3,sc4,sc5,midterm,final,total, grade) to the output file.
My idea looks very simple to the problem. I think it may not that simple as i think. Please guide me.
-First we have to scan the details from input file
-if the score is > 0 and < 100 then
1)calculate average score for programs (total all score and divide by 5)
2) student total score i.e 30%*total program score+35%midterm+35%*final+5%
Else
display "the score is not a valid one"
3)calculating grade
If Marks >=90 and <=100 then
Display grade = ‘A’
Else if marks >= 80 and <=89 then
Display grade = ‘B’
Else if marks >= 70 and <=79 then
Display grade = ‘C’
Else if marks >= 60 and <=69 then
Display grade = ‘D’
Else if marks >=0 and <=59 then
Do display grade = ‘F’
4) calculate total class score
Please let me know if iam right. If possible please tell me how to start writing C code for this or the pseudocode
Thanks for your help
I just joined the post. Iam new to C programming. I have a question regarding a problem i found in some book. The problem is i have a input file with student ID, 5 program scores, midterm and final score. i have to check for wrong input of data(negative score),calculate average score for program,calculate student totalscore (30% of programming,30% midterm,35%final and 5%free for whoever takes final exam),give grade to student and then finally compute calss total score.
print in a format (sID,sc1,sc2,sc3,sc4,sc5,midterm,final,total, grade) to the output file.
My idea looks very simple to the problem. I think it may not that simple as i think. Please guide me.
-First we have to scan the details from input file
-if the score is > 0 and < 100 then
1)calculate average score for programs (total all score and divide by 5)
2) student total score i.e 30%*total program score+35%midterm+35%*final+5%
Else
display "the score is not a valid one"
3)calculating grade
If Marks >=90 and <=100 then
Display grade = ‘A’
Else if marks >= 80 and <=89 then
Display grade = ‘B’
Else if marks >= 70 and <=79 then
Display grade = ‘C’
Else if marks >= 60 and <=69 then
Display grade = ‘D’
Else if marks >=0 and <=59 then
Do display grade = ‘F’
4) calculate total class score
Please let me know if iam right. If possible please tell me how to start writing C code for this or the pseudocode
Thanks for your help
Hmmm almost there.
You just need to change
Why cant the score be 100 ?
Just loop through the scores, and at the same time check for the above condition, if not satisfied duck out of the program using "exit (1)" or just consdier the score as 0 and move on.
And to start off programming there are many basic tuts on the C language in the forum sticky at the top of C++ forum here.
Or if you know a bit of C just post what you can do and we will try to help you out.
You just need to change
•
•
•
•
if the score is > 0 and < 100 then
Just loop through the scores, and at the same time check for the above condition, if not satisfied duck out of the program using "exit (1)" or just consdier the score as 0 and move on.
And to start off programming there are many basic tuts on the C language in the forum sticky at the top of C++ forum here.
Or if you know a bit of C just post what you can do and we will try to help you out.
I don't accept change; I don't deserve to live.
You also don't need the range in the IF's. For example
C++ Syntax (Toggle Plain Text)
IF score > 90 ; this will take everything above 90... Display A ; Output grade and the IF is over else IF score > 80 ; this will take everything above 80... Display B ; anything above 90 has already been taken care of above else ...
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
•
•
Thanks for your reply too. I did write a program like u said. But i don't want it to take value beyond 100 i.e 101 or 102..... so that is reason i put them in the range.
What do you know about arrays?
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- Algorithm problem (Computer Science)
- user input random amount display average. little problem i have run into (Java)
- Confusion about Algorithm Analysis Problem. (Computer Science)
Other Threads in the C++ Forum
- Previous Thread: Simple while loop in c++
- Next Thread: - Visualisation
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game getline google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






