c++ HELP!! 9 replies

Please wait...

kotfquig

Master skinner-in my mind :-P

50 XP

2nd August 2004

0 Uploads

284 Posts

0 Threads

#1 13 years ago

ok i need this stupid project done by 2maro, and i dont know wtf to do!! so far im pretty good at my intermediate programming coarse and usually finishe before everyone else but this project... idk if its the math or my coding but i just cant get it to work ok here are the specifications of the program it needs to use a data file first number is the amount of grades there are then the rest are the grades next i need to use a vector and declare its size by using the first number in the data file (it wont stop giving me max index error no matter what i do) then i need to calculate the average of all the grades (easy) now this is the tricky part... i need the standard deviation of the grades using the bell curve soooo....... yea... n e help possible would be greatly appreciated!




colonel_bob

Here & There

50 XP

4th June 2004

0 Uploads

6,685 Posts

0 Threads

#2 13 years ago

I can help you with the programming, but not the math. Actually, I'm not sure if I can help you with the programming (I've been taking Java for the past two years), but I'll try anyway. If I'm not mistaken, using the cin operator will seperate all the input from the whitspaces. This makes reading in your array easy; use the first cin as an int, and then declare the array for that size and do the rest of the input in a for loop like this: for (int i=0;i<(your variable name);i++), and just cin the rest of the vector with vectorname[i]. Sorry if that was a bit confusing, I haven't worked with the language for a while, but... hope it helps.




kotfquig

Master skinner-in my mind :-P

50 XP

2nd August 2004

0 Uploads

284 Posts

0 Threads

#3 13 years ago

no its not at all confusing, and i wish it was that simple but its not if it was simple cin statements then id be fine, because i did a similar program using cin statements (only to calculate the average but using a vector) but this needs to have the "grades" or numbers read in from a data file ie: i need to make a file named "something.dat" which contents are something like 9 (number of total grades) 90 (\/ the actual grades) 90 90 95 95 95 100 100 100 then i have to use infile>>x; which would be my variable and resize it to the first number, in this case being nine, but so far im screwed because it keeps saying the max index is 1 number smaller for some reason (in this case being 8) so it shuts down the program when it tries to store the nineth number then of coarse is the tricky part of the standard deviation, but i think with some work, and some help from my teacher (who is also fortunatly a math teacher :D ) i think i can figure that out so again, n e and all help will be appreciated!




Kilobyte

What does the Fox say?

69,060 XP

23rd November 2002

0 Uploads

6,468 Posts

0 Threads

#4 13 years ago

Does the code work if the variable is ten? Just out of curiousity.

I dropped a few words into Google, to see if I could get a clearer understanding of C++ programming. I still haven't gotten past the basics "Hello Word"... :rolleyes:

This was the closest thing that came up, but I am not sure if it is C++, even though it is a page about programming, Bell Curves, and is a part of a C++ programming course. http://www.taumoda.com/web/class/day31.html




Stahlbrand

{48th}Maj. Stahlbrand

50 XP

3rd April 2005

0 Uploads

277 Posts

0 Threads

#5 13 years ago

I don't know much at all about C++, but does it have built in math functions?




Revenge VIP Member

Shizzle my nizzle

117,165 XP

28th July 2004

0 Uploads

10,354 Posts

0 Threads

#6 13 years ago

Well here's how SD works: sdeviation2.gif Lower-case sigma is the standard deviation; X-bar is another way of saying the average of X; n-1 is the total number you are wanting to find the deviation of minus 1; You square it so that you are guarenteed a positive integer.




metal_militia

Killing is my business...

50 XP

29th November 2004

0 Uploads

1,759 Posts

0 Threads

#7 13 years ago

I would help but i dont know what you are asking :/ Perhaps post more info.




colonel_bob

Here & There

50 XP

4th June 2004

0 Uploads

6,685 Posts

0 Threads

#8 13 years ago
kotfquigthen i have to use infile>>x; which would be my variable and resize it to the first number, in this case being nine, but so far im screwed because it keeps saying the max index is 1 number smaller for some reason (in this case being 8) so it shuts down the program when it tries to store the nineth number

Well, remember, the array's indicies start with zero and go up to eight (for an array with 9 elements), so you can't really have the first fin statement in the for loop. After reading in the number of elements, just go throught the for loop starting with zero (int i=0) untill one before the number of elements (i




kotfquig

Master skinner-in my mind :-P

50 XP

2nd August 2004

0 Uploads

284 Posts

0 Threads

#9 13 years ago

well i got it today, and yea it was something COMPLETELY stupid i forgot it started counting at 0 lmao so i was trying to assign 1-9 instead of 0-8 and thats what was giving me the problem then it was just about 10 min of looking in my math notes for how to do the standard deviation and i got the program working and got full credit for it so thanks for all the help!




Napoleon08

Slightly cooler than a n00b

50 XP

17th May 2005

0 Uploads

44 Posts

0 Threads

#10 13 years ago

like I know anything about c++ yeah right.