PDA

View Full Version : Need help with C



Beretta
03-09-2009, 10:50 PM
Based on the solution of assignment #2, using exactly the same computation to determine the grade, write a program to compute the grade for a class of students. To indicate that there is no more scores; use a negative # as the first assignment score.
If assign. #1 score is negative; your program should terminate without the need to read in the rest of the scores. However, for this assignment, it is acceptable to still require input for other assignment scores if assignment #1 score is part of ONE input statement for all scores of a student.

In addition to compute and report the grade of each individual student, output a summary report showing the total number of students, and the number of students receiving each letter grade.

No credits will be given if the program contains any
compile-time or run-time error.
Remember to comment your program, uses meaningful variable names,
Have good indentation, echo-print your input, etc.

Grading scheme:
If the first assignment score for a student is O.K., then
Normal computation if all other scores are within range
If any other scores are not good, then do not count that student (ignore the rest of the score). It is also acceptable if the program repeats asking until all good scores are obtained, in that case, you have normal computation.

Maximum point Deductions for programs that can execute, and give correct answers:
1. require to input the total number of students to control the loop 10
2. keep asking whether there are more students to control the loop 2
3. A sequence of if ‘s (not using else if’s) 5
4. does not check score between 0 and 100 10
Minimal acceptable program: if any input score out of range, output an error statement and ignore the student.
Better solutions are also acceptable.
5. Minor mistakes in getting the Wrong answers for grades (A,B,C, etc.) 10
6. Minor mistakes in getting the Wrong counts for grades (A,B,C, etc.) 10
7. comments, indentation, prompts, etc. 20


that is my assignment and here is my finished assignment #2.

#include <stdio.h>
#include <stdlib.h>

int main()
{
int asgn1, asgn2, asgn3, asgn4, test1, test2, exam, a1good, a2good, a3good, a4good, t1good, t2good, egood, asum, tsum, esum;
float weight1, weight2, weight3, allscore, score;
char grade;

//asks to enter in all the grades of the student (meaning input)
printf("Please enter four assignment grades, two test grades, and one exam grade:\n");
printf("Enter first assignment grade: ");
scanf("%d", &asgn1);
printf("Enter second assignment grade: ");
scanf("%d", &asgn2);
printf("Enter third assignment grade: ");
scanf("%d", &asgn3);
printf("Enter fourth assignment grade: ");
scanf("%d", &asgn4);
printf("Enter first test grade: ");
scanf("%d", &test1);
printf("Enter second test grade: ");
scanf("%d", &test2);
printf("Enter exam grade: ");
scanf("%d", &exam);
//now to make sure grades are within the appropriate range will will declare parameters from 0 to 100.
a1good=asgn1>=0&&asgn1<=100;
a2good=asgn2>=0&&asgn2<=100;
a3good=asgn3>=0&&asgn3<=100;
a4good=asgn4>=0&&asgn4<=100;
t1good=test1>=0&&test1<=100;
t2good=test2>=0&&test2<=100;
egood=exam>=0&&exam<=100;
allscore=a1good, a2good, a3good, a4good, t1good, t2good, egood;
if(allscore)
{
printf("all scores are good for calculation\n");
}
else
{
printf("one or more scores are bad, please re-enter the scores\n");
system("pause");
return 0;
}
//now we must calculate the needed scores and percentages
asum = asgn1 + asgn2 + asgn3 + asgn4; // assignment sum
weight1 = (asum/4)*.2; // assignment weighed at 20%
printf("Your weighted assignment grade is=%f\n", weight1);
tsum = test1 + test2; // test sum
weight2 = (tsum/2)*.3; // test weighed at 30%
printf("Your weighted test grade is=%f\n", weight2);
weight3 = exam*.5; // exam weighed at 50%
printf("Your weighted exam grade is=%f\n", weight3);
score = weight1 + weight2 + weight3;
if(score<=100 && score>=85) // if statements will
{
grade = 'A';
}
else if(score<85 && score>=74)
{
grade = 'B';
}
else if(score<74 && score>=63)
{
grade = 'C';
}
else if(score<63 && score>=52)
{
grade = 'D';
}
else if(score<52 && score>=0)
{
grade = 'F';
}
else if(score<0)
{
grade = 'N';
}
printf("grade=%c\n", grade);
system("pause");
return 0;
}

:banana::banana::banana::banana: is a bit sloppy, but im totally confused on what to do.
anyone care to help out?