Writing code help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marmar12
    New Member
    • Mar 2008
    • 11

    Writing code help

    Hi guys,

    I'm having a little difficulty and kind of stuck writing this particular code for a grade calculator project. I'm using linux OS.

    So far, i have:

    #include <stdio.h>
    int man()

    {
    int my grade; /* user's grade */
    printf ("welcome....." );
    printf("Enter HW1 score (out of 100");
    printf("Enter HW2 score (out of 100");
    printf("Enter HW3 score (out of 100");
    printf("Enter Proj1 score (out of 100");
    printf("Enter Proj2 score (out of 100");
    printf("Enter Proj3 score (out of 100");
    printf("Enter Proj4 score (out of 100");
    printf("Enter Exam1 score");
    printf("Enter Exam2 score");
    printf("Enter Exam3 score");


    Then im stuck. My question is, lets say i give the avg score of HW= A, and Proj = B and Exam= C. Given that HW= 12% of grade, Proj=28% and Exam=60%. So final equation is: (A x .12) + (B x .28) + (C x .60) = Final Grade.

    -How can i input that equation into the code inorder for it to compile and give me that final grade?
    -Are there any necessary loops to use?

    I extremely appreciate your help. Thanks.
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by marmar12
    Hi guys,

    I'm having a little difficulty and kind of stuck writing this particular code for a grade calculator project. I'm using linux OS.

    So far, i have:

    #include <stdio.h>
    int man()

    {
    int my grade; /* user's grade */
    printf ("welcome....." );
    printf("Enter HW1 score (out of 100");
    printf("Enter HW2 score (out of 100");
    printf("Enter HW3 score (out of 100");
    printf("Enter Proj1 score (out of 100");
    printf("Enter Proj2 score (out of 100");
    printf("Enter Proj3 score (out of 100");
    printf("Enter Proj4 score (out of 100");
    printf("Enter Exam1 score");
    printf("Enter Exam2 score");
    printf("Enter Exam3 score");


    Then im stuck. My question is, lets say i give the avg score of HW= A, and Proj = B and Exam= C. Given that HW= 12% of grade, Proj=28% and Exam=60%. So final equation is: (A x .12) + (B x .28) + (C x .60) = Final Grade.

    -How can i input that equation into the code inorder for it to compile and give me that final grade?
    -Are there any necessary loops to use?

    I extremely appreciate your help. Thanks.

    You can have the formula in the code itself.
    First you need to storethe values entered by the user.
    You can multiply the input entered by the user and do the sum and then print the output. like this
    [code=c]
    //(A x .12) + (B x .28) + (C x .60) = Final Grade.
    double final_grade = (v1 * .12) + (v2 * .28) + (v3*.60);
    //here v1,v2,v3 are the values entered by the user

    [/code]

    Raghuram

    Comment

    • marmar12
      New Member
      • Mar 2008
      • 11

      #3
      Originally posted by gpraghuram
      You can have the formula in the code itself.
      First you need to storethe values entered by the user.
      You can multiply the input entered by the user and do the sum and then print the output. like this
      [code=c]
      //(A x .12) + (B x .28) + (C x .60) = Final Grade.
      double final_grade = (v1 * .12) + (v2 * .28) + (v3*.60);
      //here v1,v2,v3 are the values entered by the user

      [/code]

      Raghuram

      Is that the "ibase" command for storing the values entered?
      What does that "double" signify?

      Thanks.
      Last edited by marmar12; Apr 1 '08, 03:56 AM. Reason: adding somethign

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        Originally posted by marmar12
        Is that the "ibase" command for storing the values entered?
        What does that "double" signify?

        Thanks.
        since you multiply all the variables by a float value i have gone for double


        Raghu

        Comment

        • satch
          New Member
          • Feb 2008
          • 23

          #5
          Originally posted by marmar12
          Is that the "ibase" command for storing the values entered?
          What does that "double" signify?

          Thanks.
          'double' is a datatype like int and char. (Read about c++ datatypes and you'll find it.)
          Btw what is an ibase command?

          Comment

          • marmar12
            New Member
            • Mar 2008
            • 11

            #6
            Originally posted by satch
            'double' is a datatype like int and char. (Read about c++ datatypes and you'll find it.)
            Btw what is an ibase command?

            i looked online for an example on what command to use to "store" values and all i could find was this command called "ibase". Could you provide me an example on how to write the command for storing values/integers?

            Thanks.

            Comment

            • satch
              New Member
              • Feb 2008
              • 23

              #7
              Originally posted by marmar12
              i looked online for an example on what command to use to "store" values and all i could find was this command called "ibase". Could you provide me an example on how to write the command for storing values/integers?

              Thanks.
              So I think that what you want is a method to store user input in variable. In that case there is a function scanf using which you can store the values given by the user into variables. Read the documentation for scanf. Its similar to printf.

              Comment

              Working...