944,050 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2355
  • C RSS
Sep 6th, 2006
0

grade prediction program

Expand Post »
here is my code i get an error of call of non function in lines 29, 34, 39 and 44


apprecite help or an alternate code if possible

here is code
  1. int main (void)
  2. {
  3. char desiredgrade;
  4. double min_average;
  5. double currentaverage;
  6. double weight;
  7. double score;
  8. printf("Please enter your desired grade: \n");
  9. scanf("%c", &desiredgrade);
  10. printf("Please enter your minimum average required: \n");
  11. scanf("%lf", &min_average);
  12. printf("Please enter your current average in course: \n");
  13. scanf("%lf", &currentaverage);
  14. printf("Please enter how much the final counts as a percentage of the course grade: \n");
  15. scanf("%lf", &weight);
  16. if ( 92<=desiredgrade && desiredgrade>=100)
  17. {
  18. score=(min_average-(100-weight)(currentaverage/100)+(100/weight));
  19. printf("You need a score of %.2f on the final to get A\n",score);
  20. }
  21. else if (84<=desiredgrade && desiredgrade>=91)
  22. {
  23. score=(min_average-(100-weight)(currentaverage/100)+(100/weight));
  24. printf("You need a score of %.2f on the final to get B\n",score);
  25. }
  26. else if (76<=desiredgrade && desiredgrade>=83)
  27. {
  28. score=(min_average-(100-weight)(currentaverage/100)+(100/weight));
  29. printf("You need a score of %.2f on the final to get C\n",score);
  30. }
  31. else if (68<=desiredgrade && desiredgrade>=75)
  32. {
  33. score=(min_average-(100-weight)(currentaverage/100)+(100/weight));
  34. printf("You need a score of %.2f on the final to get D\n",score);
  35. return 0 ;
  36. }
  37. return score ;
  38. }
Last edited by WolfPack; Sep 6th, 2006 at 1:09 pm. Reason: Code Tags
Similar Threads
Reputation Points: 30
Solved Threads: 0
Newbie Poster
hygy486 is offline Offline
7 posts
since Sep 2006
Sep 6th, 2006
0

Re: grade prediction program

You need some kind of operator between these brackets. Probably the multiplication operator. (a)(b) doesnt mean a * b like in algebra.

   score=(min_average-(100-weight)(currentaverage/100)+(100/weight));
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Sep 6th, 2006
1

Re: grade prediction program

then that makes my formula wrong then
that is correct formula
Reputation Points: 30
Solved Threads: 0
Newbie Poster
hygy486 is offline Offline
7 posts
since Sep 2006
Sep 6th, 2006
0

Re: grade prediction program

If that doesnt correct your problem write me the Correct Formula mathematically. Use +,-,*,/ only. Don't use any implicit operators.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Sep 6th, 2006
1

Re: grade prediction program

Purpose: To determine data requirements.
To read input.
To process and output data.
To document a program.

Program: Write a program that predicts the score needed on a final exam to achieve a desired grade in a course. The program should interact with the user as follows:
Enter Desired grade: B
Enter minimum average required: 79.5
Enter current average in course: 74.6
Enter how much the final counts as a percentage of the course grade: 25

You need a score of 94.20 on the final to get a B.

[79.5 - 75(.746)] * 4

this is waht his example works out to i need the formula
Reputation Points: 30
Solved Threads: 0
Newbie Poster
hygy486 is offline Offline
7 posts
since Sep 2006
Sep 6th, 2006
0

Re: grade prediction program

Click to Expand / Collapse  Quote originally posted by hygy486 ...
Enter Desired grade: B
Enter minimum average required: 79.5
Enter current average in course: 74.6
Enter how much the final counts as a percentage of the course grade: 25

You need a score of 94.20 on the final to get a B.
[79.5 - 75(.746)] * 4
Here is a much more smaller program that gives you the required output. No check is done for Desired grade checking. You do that.
  1. #include <stdio.h>
  2.  
  3. int main (void)
  4. {
  5. char desiredgrade;
  6. double min_average;
  7. double currentaverage;
  8. double weight;
  9. double score;
  10. printf("Please enter your desired grade: \n");
  11. scanf("%c", &desiredgrade);
  12. printf("Please enter your minimum average required: \n");
  13. scanf("%lf", &min_average);
  14. printf("Please enter your current average in course: \n");
  15. scanf("%lf", &currentaverage);
  16. printf("Please enter how much the final counts as a percentage of the course grade: \n");
  17. scanf("%lf", &weight);
  18. score=(min_average-((100-weight)*(currentaverage/100)))*(100/weight);
  19. printf("You need a score of %.2f on the final to get %c\n",score, desiredgrade);
  20.  
  21. return 0;
  22. }
My output
  1. Please enter your desired grade:
  2. B
  3. Please enter your minimum average required:
  4. 79.5
  5. Please enter your current average in course:
  6. 74.6
  7. Please enter how much the final counts as a percentage of the course grade:
  8. 25
  9. You need a score of 94.20 on the final to get B
Last edited by WolfPack; Sep 6th, 2006 at 2:39 pm. Reason: removed "return score;" score is of type double. main returns int.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Sep 7th, 2006
2

Re: grade prediction program

Yes you better follow the guidelines laid down by Wolfpack to solve your problem but while finalizing your code just replace the [inlinecode] scanf[/code] with either getchar () for gettign a character or fgets ( ) while getting a string.

scanf is a prettly complex function and leaves the input stream dirty with the junk.

Hope it helped, bye.
Last edited by ~s.o.s~; Sep 7th, 2006 at 2:04 pm.
Super Moderator
Featured Poster
Reputation Points: 3241
Solved Threads: 720
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC