Hmm...when you say you are having problem what does it actually mean ?
Some more things, if your program wants to calculate the average, where is the array which holds the values or are you accepting input from a file ?
In your get_data( ) function you have :
final = static int which has value between 29 and 49.
What is the significance of this in the algorithm ?
Also you are not seeding the random number so your random numbers would be repetitive and not quite random in nature as you would expect them to be.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Paste your entire question as it is word to word and then maybe I would be able to help you out because your description is rather vague.
And btw if you don't know what you are doing, how come did you write his code ?
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
But the above problem can't be solved without arrays if you want to store the scores for later display.
Maybe you should brush up a bit on arrays from your text book and then try to attempt the problem.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
I again repeat myself:
In order to get the output of the form given by you, arrays are a must.
Scores:
43 58 100 79 100 100 93 100 82 100 100 46 100 100 75 97 82 85 89 100 61 100 100 86 100
Weights:
5 5 5 10 5 5 5 5 5 10 10 10 5 10 5 5 5 5 10 25Without arrays you won't be able to display the records in the given format and finding out the grade would be really difficult.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
i have given up on the array idea
Listen to what ~s.o.s~ said. Use arrays! If you can't figure out how to use arrays, avoiding it isn't going to help. Even if you do manage to avoid it now, what is going to save you when you are forced to use them?
Quite simply, here is a (random) example of entering data (haven't compiled the code or anything, so there could be errors):
int main() {
int array[40]; // this array holds 40 elements
for (int i=0; i<40; i++) { // loop 40 times; 'i' iterates
cout << "\nEnter int: ";
cin >> array[i]; // store data in current spot
cout << endl;
}
// data is now stored
// print out data
for (int i=0; i<40; i++) {
// print "Data for [0] is 50"
// "Data for [1] is 43", etc
cout << "Data for [" << i << "] is " << array[i] << endl;
}
}
Once you've figured out why arrays are useful, and how to use/access them, then it should be easy to find weighted data and print out scores.
Hope this helps
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
Working with these lists of number is most easily done with an array. I think (if I understand this assignment correctly) that it could be done without them, but in a very cumbersome, roundabout manner. Here's 2 ways to do this:
- Use arrays. Take your input, put all of the scores into one array and all of the weights into another. Although you've demonstrated a disinterest in learning new things, you might want to look into using the std::vector class, which is essentially a dynamically sized array. After you've gotten all the input, you can calculate the sum of each list, and do the math you need to do with that. You can also print the lists and results from the array's you have and the math you've just done. That's about it.
- If you truly refuse to use arrays, you can input the data in pairs (e.g. "Enter a score: " followed by "Now enter a weight: "). For each one, add it to a string for that row, that is, one for scores and one for weights. Also add the value to a sum for each row. At the end you'll still have the sums and the strings you need to output, and you can proceed to do whatever math you need to do. This is IMHO a less elegant solution, but should still get the job done...
Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53
naw, save your money!
You have all the qualifications for a long career in the fast food industry. LOL
JRM
Practically a Master Poster
621 posts since Nov 2006
Reputation Points: 130
Solved Threads: 75
I hate it when people thing that money can get them through whatever problems are in front of them... that said, I'll do it for $200, 1/2 of it up front (after I go sign up for paypal)...
Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53
yeah, LOL
sladkjflsadkfj;saldfj crap
cout << "shoot me in the face" <<
If you understand what you're doing, you're not learning anything. Programming is like that. We all struggle to learn new concepts, and I think that it's the satisfaction in overcoming these concepts that makes programming worthwhile. It's a challenge.I hate it when people thing that money can get them through whatever problems are in front of them... that said, I'll do it for $200, 1/2 of it up front (after I go sign up for paypal)...
LOL. I wouldn't mind doing it except I'd have this guilty feeling that I shouldn't be doing it :o...
:cheesy:
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
wanna post the code you have so far?
Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53