# Ignoramus needs help with a Simple Grade program.

• 10-08-2012
Kurtanius21
Ignoramus needs help with a Simple Grade program.
Hello Everyone, I'm new to this board. I'm taking a class of which I have not taken the prerequisite. I have never programmed before, and now I have a simple program due tomorrow, and I'm at a loss at how to do it. Here's the problem

“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 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.”

I have no idea how to deal with the letter 'B' How do I assign a value to it? How do I use printf and scanf with this variable? I can manage the numerical operations, but I just really need help with the letter part of this assignment. Please let me know if you need clarification. Thanks!

- Kurt
Code:

```      1 # include <stdio.h>       2       3 int main ()       4       5 {       6       7          8    double desired, minimum, current, final;       9    printf("Enter desired grade> ");     10    scanf("%lf", &desired);     11    printf("Enter minimum average required> ");     12    scanf("%lf", &minimum);     13    printf("Enter current average in course> ");     14    scanf("%lf", &current);     15    printf("Enter how much the final counts\n");     16    printf("as a percentage of the course grade> ");     17    scanf("%lf", final);     18     19 } ~```
Attachment 12049
• 10-08-2012
stahta01
http://www.cplusplus.com/reference/c.../cstdio/scanf/

The information is almost all C (instead of C++ as newbies sometimes think) on the link above.

Code:

```#include <stdio.h> int main () {     char desired;     double minimum, current, final;     printf("Enter desired grade> ");     scanf(" %c", &desired);     printf("Enter minimum average required> ");     scanf("%lf", &minimum);     printf("Enter current average in course> ");     scanf("%lf", &current);     printf("Enter how much the final counts\n");     printf("as a percentage of the course grade> ");     scanf("%lf", &final);     return 0; }```
I changed grade to be a char.

The space before the %c skips over the possible space/newlines.
Code:

`scanf(" %c", &desired);`
Tim S.
• 10-08-2012
Click_here
Quote:

I'm taking a class of which I have not taken the prerequisite

Start at "Intro to C" and work your way though
• 10-08-2012
Click_here
Also note that it is against forum policy to do your homework for you.
• 10-08-2012
stahta01
Quote:

Originally Posted by Click_here

Start at "Intro to C" and work your way though

You should also read over the input/output intro to C stuff in the Intro.
Link to output FAQ; I could not find the input of char FAQ.

FAQ > Format output using printf() (C) - Cprogramming.com
• 10-08-2012
Kurtanius21
Hey everyone, I got the thing to work. Thanks for your help. The tutorial helped a lot, but now I have another question! I will create a new thread.
• 10-08-2012
Matticus
Quote:

Originally Posted by Click_here
Also note that it is against forum policy to do your homework for you.

Please note that the OP clearly stated the specs, the problem, and also some code, in addition to their question. I personally don't see anything here that goes against the homework policy.
• 10-08-2012
Click_here
Quote:

Originally Posted by Matticus
Please note that the OP clearly stated the specs, the problem, and also some code, in addition to their question. I personally don't see anything here that goes against the homework policy.

I never said that it did - It was my way of saying that they should be aware that they need to do the work.

I get suspicious whenever I see something like, "I have a simple program due tomorrow, and I'm at a loss at how to do it".

You're right that it was a unnecessary.