Computing.Net > Forums > Programming > C/C++ Program

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C/C++ Program

Reply to Message Icon

Name: Zeff
Date: September 15, 2006 at 07:34:45 Pacific
OS: XP Pro SP2
CPU/Ram: 1GB
Comment:

I have this program which I have to do. I am stuck because I haven't been programming in a while, therefore I forgot a couple of things. If anyone would be able to help me with anything and get me started with this program, I would be very grateful.

Here it is:
This Program should calculate weighted averages of grades. The program should also help answer this question: “how much to I have to get on the final in order to get an (x)?”

The program should open with heading on the screen which asks the user how many tests will be given during a semester. Then, the program should this number, n, and an empty integer array, percentages, to a void function. The void function should fill percentages by asking the user what percent of the grade is each test. The sum of all the percentages must be 100. If it is not there should be error message which should make the user reenter the information.

Once the percentages array is full, you should give the user one of two options. (Each of these options should be done by done by a separate function)

1) Allow the user to enter the n test grades and calculate the weighted averages of the grades. (Hint: if pi is the i-th percentage and ti is the i-th grade, then average = ni=1 pi * t¬i.)

2)Allow the user to enter in n-1 grades. First ask the user which test grade, k, the user is not entering (note 1kn.) Then enter in all but the k-th grade (hint: use continue in a for loop). Ask the user what he would like to get above as an average. Call this double variable above. Then calculate and print what the student needs to get in the k-th test to earn a grade higher then above. (Hint: If x denotes the unknown k-th grade then we have the following inequality: =ik pi * t¬i + pk*x  above. Now simply solve for x.)

Once this is done, allow the user to enter in the information for another student, or an option to stop.

p.s. if anyone would like to email me with any questions or suggestions please do. Thanks again for any help.




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 15, 2006 at 07:41:24 Pacific
Reply:

Have you done your pseudo-code?


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: Zeff
Date: September 16, 2006 at 10:09:55 Pacific
Reply:

No I haven't. I'm just lost with this program. I haven't been anywhere near programming for a long time, and I'm just blanking.


0

Response Number 3
Name: Rolos
Date: September 18, 2006 at 03:07:40 Pacific
Reply:

The instructions in this paragraph are fairly straight forward. You're basically getting the number of tests (n) and passing that to your void function, along with an integer array, and a percentage array.

Your void function will be gathering the grade and percentage data and stuffing them into the arrays you give it.

so tab your void function...

void get_data(int array[],
int percentages[],
int n);

next step is to work on getting the number of tests in main() then making a call to your function:

int n;
int grades[];
int percentages[];

cout << "How many tests?" << endl;
cin >> n;

/* pass your arrays and 'n' to your void function to fill the array and get the percentages. make sure to do the error checking as well (percentages must add up to 100). */

get_data(grades, percentages, n);

------------

So your main should look something like this (keep in mind that the code I'm giving you is NOT code, it is pseudocode that has some C++ syntax:

void get_data(int grades[],
int percentages[],
int n);

int main()
{
// declare variables.
int n;
int grades[];
int percentages[];

// 1. get the number of tests.
// 2. call your function and give it the appropriate arguments.

return 0;
}

------------

This should give you a jump start on your assignment. Keep in mind that for the remainder of the assignment you will do a lot of array scanning, and modifications so do this with for loops or while loops.

Also, you may want to test out your void function prototype. Remember that your void function doesn't have to be 100% funtional in order to test it. For example, have it print out the value of n inside of your void function to ensure that n is being passed correctly.

In other words, if you enter '10' as the number of tests, have your void function print out n to ensure that n is actually '10'.

Hope this helps you.

- Rolos


0

Response Number 4
Name: Rolos
Date: September 18, 2006 at 03:08:14 Pacific
Reply:

*Instructions in the first paragraph...


0

Response Number 5
Name: Zeff
Date: September 26, 2006 at 16:03:59 Pacific
Reply:

Thanks !! it does help .. I have started the program, and done a lot of it. I'll post anything if I have a problem with it .. thanks


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C/C++ Program

c++ programming for novell www.computing.net/answers/programming/c-programming-for-novell/2525.html

Bike Trader C program www.computing.net/answers/programming/bike-trader-c-program/6557.html

C++ Programming Website www.computing.net/answers/programming/c-programming-website/4752.html