Like Tree1Likes
  • 1 Post By Matticus

Ignoramus needs help with a Simple Grade program.

This is a discussion on Ignoramus needs help with a Simple Grade program. within the C Programming forums, part of the General Programming Boards category; Hello Everyone, I'm new to this board. I'm taking a class of which I have not taken the prerequisite. I ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    33

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

    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 }
    ~
    .c

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,542
    You should read about scanf
    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.
    Last edited by stahta01; 10-08-2012 at 05:17 PM.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  3. #3
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,343
    I'm taking a class of which I have not taken the prerequisite
    Here is a link that can help you C Tutorial - Learn C - Cprogramming.com

    Start at "Intro to C" and work your way though
    Fact - Beethoven wrote his first symphony in C

  4. #4
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,343
    Also note that it is against forum policy to do your homework for you.
    Fact - Beethoven wrote his first symphony in C

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    2,542
    Quote Originally Posted by Click_here View Post
    Here is a link that can help you C Tutorial - Learn C - Cprogramming.com

    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
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  6. #6
    Registered User
    Join Date
    Oct 2012
    Posts
    33
    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.

  7. #7
    Registered User
    Join Date
    Jun 2011
    Posts
    2,269
    Quote Originally Posted by Click_here View Post
    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.
    somali.cc likes this.

  8. #8
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,343
    Quote Originally Posted by Matticus View Post
    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.
    Fact - Beethoven wrote his first symphony in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Grade my first lab? (and program :D)
    By Cowmoogun in forum C Programming
    Replies: 21
    Last Post: 02-22-2012, 07:08 AM
  2. Grade Program
    By Jbrubin in forum C Programming
    Replies: 2
    Last Post: 03-28-2011, 02:02 PM
  3. Replies: 2
    Last Post: 01-29-2011, 11:58 AM
  4. grade program code
    By jd7joe in forum C++ Programming
    Replies: 8
    Last Post: 11-18-2005, 03:48 PM
  5. Student Grade Program
    By Vinod Menon in forum C Programming
    Replies: 1
    Last Post: 05-31-2004, 12:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21