Thread: Problem with calculations

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    1

    Problem with calculations

    This program should allow you to enter the percentage desired
    at the end of a course, the total number of points in the
    course, the points earned to date, and the total points to
    date. The program should then calculate and display:
    1) the number of the remaining points in the class needed to
    earn the desired percentage
    2) the percentage of the remaining points needed to earn the
    desired percentage in the course.

    Read the input in the order below: (Don't read anything else.)
    1) Percentage desired
    2) Total points in the course
    3) Points earned to date
    4) Total points to date

    Heres is what I have got so far. I am not sure how to convert the formula over to C code

    #include <stdio.h>
    int main ()
    {
    float percent;
    int totalpoints;
    int earnedpoints;
    int totaltodate;
    printf("Enter Percentage Desired:");
    scanf (" %d", & percent);
    printf("Enter Total points in the course:");
    scanf ("%d",& totalpoints);
    printf("Enter Total points earned to date:");
    scanf("%d ", &earnedpoints);


    printf("Enter Total points to date:");
    scanf("%d",&totaltodate);

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Welcome! Read the announcements, especially the part about using code tags.

    The first step would be to write out the formulas using standard math. Then coding it in C is pretty simple.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  3. #3
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Damn! Beaten.

    I think it'd also be a better idea if the program calculated the % for you....

    Code:
    #include <stdio.h>
    
      int main(){
      float curPoints;
      float maxPoints;
      float percent;
    
         printf("Enter your current points:\t");
         scanf("%f",&curPoints);
         printf("\nNow enter the max points possible:\t");
         scanf("%f",&maxPoints);
         percent = (curPoints/maxPoints) * 100;
    
         printf("\nHey, you have a %f percent, guy!",percent);
    return 0;
    }
    Just use some good ol' math, honey. Also...it seems that you're entering a value for "total points"...twice?

    totalpoints and totaltodate?
    Last edited by Krak; 03-03-2005 at 02:20 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  4. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  5. array problem?
    By ssjnamek in forum C Programming
    Replies: 14
    Last Post: 02-08-2006, 06:03 PM