yea, I had to take the AP calc and my teacher seems to not care that I missed the lesson so can some1 just gimme the code for this: LAB # 3 - Use the text file <testScores.txt> for this program. Write a program that prompts the user for a last name and then reads the text file and computes and outputs the average test score for the person whose name is entered. Do not use an array. The text file is unchanged. <testScores.txt> : Owen Astrachan 95 Lisa Brock 91 Bill Morrison 83 Dave Reed 56 Steve Tate 68 Owen Astrachan 77 Bill Morrison 73 Lisa Brock 75 Steve Tate 84 Mike Clancy 94 Mike Clancy 64 Lisa Brock 79 Owen Astrachan 81 Bill Morrison 89
I know this is months late =D But what ver of c++ were you using? The Visual Studio (Newer) or older standalone ver from around 2001. Seems a silly question but some of the commands are different and this really tripped me up when I dl'ed MSoft VStudio to do my C++ homework on =|
Sigh, no offense, but questions like these really bug me. They show how giant corporations like Microsoft totally brainwash people in terms of everything. The Visual Studio is a new thing (and quite a bad thing IMHO). C++ is an age-old, totally pwnful and 1337 language. NO ONE refers to VC++ as C++ (unless they are a total idiot and doesn't deserve to be a programmer -.-). There is no comparison as to which language is better IMHO and there should be no mixing-up of the two. Microsoft is just trying to rub off some of the amazing success C++ has (just like how they tried with J#, evil I tell you, I was totally insulted when they released J#). Ontopic: Erm, its a bit late I guess... But... Open an ifstream w/ the file name as the parameter and just use the ifstream like cin. Read in the last name using cin. Then go into a for loop, reading to the end of the file. If the last name matches, then add to a cummulative sum variable the test score and increment a counter variable. Then at the end, print out sum/counter.
Lmao. Visual Studio is fine. I don't know many people who are brainwashed by microsoft about visual c++ because no one uses it. If you still need help with it ill write c++ code for it.
i know thats been posted up almost 6 months ago but looking at the question brings back memorys when i was still a comp sci major ... to be honest i had a assignment alot like that. reading in the text file into the program to search and find what you input.. :arf: Do not post malicious code! Next time you do something like that, you will be warned.