I need help on a simple program

I have a simple program that's bothering me because I can't do it. Can someone help me out?

"Write a program that allows you to input students' scores and weights. The program should then calculate a weighted average and score based on the data inputted by the user."

Please help me out!
Hello, you mean console application or windows CLI forms GUI?
It would be useful to show us a sample of your code thus far. Also what exactly are you stuck on? You sound like a computer science 1 student, and this sounds like a homework assignment. While we at the forums love helping people with specific, we won't do your homework for you.
Something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>

int main()
{
    // define number of scores
    const int NSCORES = 6 ;

    // variables to hold the total weighted score and the total weight
    double total_weighted_score = 0 ;
    double total_weight = 0 ;

    // accept 'NSCORES' score-weight pairs from the user,
    // accumulate the total weighted score and the total weight  as you go
    int score ;
    double weight ;
    for( int i = 0 ; i < NSCORES ; ++i )
    {
        std::cout << "enter score and weight: " ;
        std::cin >> score >> weight ;
        // TO DO: validate that score and weight are within valid ranges
        //              if not, emit a message, and repeat the above two lines

        const double weighted_score = score * weight ;
        total_weighted_score += weighted_score ;
        total_weight += weight ;
    }

    // TO DO: calculate weighted average (total_weighted_score divided by total_weight)
    //             and print it out
}
> The program you created for me isn't working. After I input the 5 scores it just ends and doesn't average them

In the two places marked with // TO DO , you are expected to add your own code to make the program complete.

Lines 18 - 21
1
2
3
4
        std::cout << "enter score and weight: " ;
        std::cin >> score >> weight ;
        // TO DO: validate that score and weight are within valid ranges
        //              if not, emit a message, and repeat the above two lines 


Lines 28, 29
1
2
    // TO DO: calculate weighted average (total_weighted_score divided by total_weight)
    //             and print it out 
"Validate" simply means to check if variables have proper values. I recommend reading up on the tutorials provided at this very site (conditions, specifically).

If you still need help, email me at: sparkprogrammer@gmail.com

Joe
Topic archived. No new replies allowed.