grade prediction program

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2006
Posts: 7
Reputation: hygy486 is an unknown quantity at this point 
Solved Threads: 0
hygy486 hygy486 is offline Offline
Newbie Poster

grade prediction program

 
1
  #1
Sep 6th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: grade prediction program

 
0
  #2
Sep 6th, 2006
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));
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 7
Reputation: hygy486 is an unknown quantity at this point 
Solved Threads: 0
hygy486 hygy486 is offline Offline
Newbie Poster

Re: grade prediction program

 
1
  #3
Sep 6th, 2006
then that makes my formula wrong then
that is correct formula
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: grade prediction program

 
0
  #4
Sep 6th, 2006
If that doesnt correct your problem write me the Correct Formula mathematically. Use +,-,*,/ only. Don't use any implicit operators.
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 7
Reputation: hygy486 is an unknown quantity at this point 
Solved Threads: 0
hygy486 hygy486 is offline Offline
Newbie Poster

Re: grade prediction program

 
1
  #5
Sep 6th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: grade prediction program

 
0
  #6
Sep 6th, 2006
Originally Posted by hygy486 View Post
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.
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,649
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: grade prediction program

 
2
  #7
Sep 7th, 2006
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.
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1838 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC