[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?

What should my For Loop say?

Posted on 2017-09-13
4
Low Priority
?
47 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 35

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

650 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