?

What should my For Loop say?

Posted on 2017-09-13
4
Low Priority
?
60 Views
Last Modified: 2017-09-28
Can someone help me write this program in c++?

 Suppose a teacher weights the four exams he gives 10%, 25%, 30%, and 35%.
Write a program that reads ten sets of four grades, prints the weighted average of each set, and prints the unweighted average of each test. The number of students should be in a global constant.

I know I need to use a for loop, but I'm not sure how to write it. Can someone show me how to code this along with guiding me through the code?
0
Comment
Question by:Kammy San Nicolas
  • 2
4 Comments
 
LVL 36

Expert Comment

by:ste5an
ID: 42292962
How should you read those then sets?
How would you store it?
0
 
LVL 35

Expert Comment

by:sarabande
ID: 42293676
as it is 4 exams and 10 students you need two loops. an outer loop for the exams and an inner loop for the students and their grades

for (int e = 0; e < NUM_EXAM; ++e)
{
        ....
        for (int s = 0; s < NUM_STUDENT; ++s)
        {
                ....

Open in new window


you could define the constants as const int above the loops.

you also could exchange the outer and inner loop (what doesn't make much difference for your program logic).

try to find out what kind of arrays you need to store the weights and the 4 times 10 grades you get as input.

Sara
1
 

Author Comment

by:Kammy San Nicolas
ID: 42294385
Thanks Sara. That helped clear things up a bit for me
0
 
LVL 35

Expert Comment

by:sarabande
ID: 42294436
if you are stuck you may post what you have so far and ask for help either with a compile error or simply how to proceed.

Sara
1

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question