C++ need help comp sci class.

Discussion in 'Code Snippets and Tutorials' started by Adam, May 16, 2008.

Thread Status:
Not open for further replies.
  1. Adam

    Adam Level III

    Joined:
    Aug 14, 2007
    Messages:
    731
    Likes Received:
    50
    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
     
  2. Excalx

    Excalx Level III

    Joined:
    Jan 19, 2007
    Messages:
    395
    Likes Received:
    0
    Location:
    A Cardboard Box
    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 =|
     
  3. Zer0

    Zer0 Level IV

    Joined:
    Mar 2, 2008
    Messages:
    3,037
    Likes Received:
    180
    Location:
    Home sweet home
    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.
     
  4. xZel

    xZel Level I

    Joined:
    Jul 25, 2007
    Messages:
    85
    Likes Received:
    5
    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.
     
  5. audio2000

    audio2000 Newbie

    Joined:
    May 26, 2008
    Messages:
    35
    Likes Received:
    1
    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.
     
Thread Status:
Not open for further replies.