Thread: Help with begginer C++ program.

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    1

    Help with begginer C++ program.

    Hi I am currently taking a Comp Sci class, its a non major course in programming in C + + , but I have found the course to be very difficult. I have to write a program by friday which will pretty much be the determining factor as to wether I pass or fail the course. Can anyone please help me with it. Any help will be greatly appreciated. Thanks in advance.
    Here is the program:

    The local baseball team is computerizing its records. You are to write a program that computes batting averages. There are 20 players in the team, identified by the numbers 1 to 20. Their batting records are coded in a file score.txt as follows. Each line contains 4 numbers: the player's identification number and the number of hits, walks and outs he or she made in a particular game. Here is a sample:

    3 2 1 4
    4 3 2 2
    5 4 1 7
    3 5 1 0

    The example above contains 5 records. The first record indicates that during a game, player number 3 was at bat 4 times and made 2 hits, one walk, and one out. For each player there are several lines in the file. Each player's batting average is computed by adding the total number of hits and and dividing by the total number of times at bat. A walk does not count as either a hit or a time at bat when the batting average is being calculated.
    For the sample shown above, player 3's total number of hits is 2 + 5 = 7 and the total number of times at bat is 2 + 4 + 5 + 0 = 11. Therefore, player 3's batting average is 7/11 = 0.64.

    Your program prints a table showing each player's identification number, batting average, and number of walks. (Be careful: The player's identification numbers are 1 through 20, but C++ array indexes start at 0.)

    Use a function to compute a player's batting average.

    Use a structure to represent player information including at least the identification number, batting average, and number of walks. You may include other information in the structure to calulate batting averages etc. Use an array of such structures to represent the baseball team.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Well this is somewhere between mildly simple and easy. You have almost complete instructions.What more do you need?
    Show us your attempt or at the very least detailed pseudocode if you want help. We are here to help and advise. We are not here to do your homework for you.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    This should be quite easy at the end of a semester of a C++ class. Have you been paying attention in class and doing your homework?, if not then you are supposed to fail , so don't fight it. If you have any specific problems i'm sure the people of this board will be happy to help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM