fork download
  1. #include <stdio.h>
  2. int main ()
  3. {
  4.  
  5. char answer[20]; /* user response to yes or no question */
  6. int score; /* test score */
  7.  
  8. printf ("\nEnter a score: ");
  9. scanf ("%i", &score);
  10.  
  11. /* Process Grade and Options based on Score */
  12. if (score <0 || score > 100)
  13. printf ("\nError, Invalid Grade \n");
  14.  
  15. else if (score >= 90) /* 90-100 */
  16. {
  17. /* you need these students, but can't make any money from them :) */
  18. printf ("\nExcellent Job: Grade is an A \n");
  19. } /* 90 - 100 */
  20.  
  21. else if (score >= 80) /* 80-89 */
  22. {
  23. printf ("\nGood Job: Grade is a B \n");
  24. printf ("Would you like an A? (y/n): ");
  25. scanf ("%s", answer);
  26.  
  27. /* Come on, answer yes, professor needs a new electronic toy */
  28. if (answer[0] == 'y' || answer[0] == 'Y')
  29. {
  30. /* All right, a customer */
  31. printf ("\nMake check payable to Tim Niesen for $200\n");
  32. printf ("... a small price to pay for your education \n");
  33. }
  34. } /* 80 - 89 */
  35.  
  36. else if (score >= 70) /* 70 - 79 */
  37. {
  38. printf ("\nFair Job: Grade is a C \n");
  39. printf ("Would you like an A? (y/n): ");
  40. scanf ("%s", answer); /* The & not needed with Arrays, will discuss this in the future */
  41.  
  42. /* time to make some real money, my favorite students */
  43. if (answer[0] == 'y' || answer[0] == 'Y')
  44. {
  45. printf ("\nMake check payable to Tim Niesen for $600 \n");
  46. printf ("... an excellent price to pay for your education \n");
  47. }
  48.  
  49. else /* maybe the student will pay to get a B ? */
  50. {
  51. printf ("\nWould you like an B? (y/n): ");
  52. scanf ("%s", answer);
  53.  
  54. if (answer[0] == 'y' || answer[0] == 'Y')
  55. {
  56. printf ("\nMake check payable to Tim Niesen for $400 \n");
  57. printf ("... a great price to pay for your education \n");
  58. }
  59. }
  60.  
  61. } /* 70 - 79 */
  62.  
  63. else if (score >= 60) /* 60 - 69 */
  64. {
  65. /* just can't make any money here, would not be right */
  66. printf ("\nPoor Job: Grade is a D \n");
  67. printf ("... You're beyond a bribe to get a better grade \n");
  68. } /* 60 - 69 */
  69.  
  70. else /* < 60 */
  71. {
  72. printf ("\nYou Failed: Grade is an F :(\n");
  73. }
  74.  
  75. return (0); /* success */
  76.  
  77. } /* end main */
Success #stdin #stdout 0.01s 5324KB
stdin
55
stdout
Enter a score: 
You Failed: Grade is an F :(