English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i need help cuz i need to make this program usin C++


You will design a program to compare the hitting performance of the Mets and Yankees so far this season. Then, we’ll see who the best team truly is!


• In the C++ folder on the groups (G:) drive, there are 2 files saved: mets.txt and yankees.txt. Both files contain the following information for each of the 15 players:

o Last Name
o First Name
o Position
o At Bats
o Hits
o Doubles
o Triples
o Homeruns


• You will write a program that will read this information into the program and then write the following information to 2 separate output files:

o Full Name – Position (Ex: Paul LoDuca – C)
o Batting Average
o Slugging Percentage


• Then, you will output the following to the screen and the bottom of both output files:

o The Mets batting average is…
o The Yankees batting average is…
o The Mets slugging percentage is…
o The Yankees slugging percentage is…


• You MUST use at least one structure

2007-05-11 03:33:00 · 3 answers · asked by brokenheart89 2 in Computers & Internet Programming & Design

i can call of the files i just need to know how to do everything else!!!....pleaz i really nedd help im compleatly clueless.....

2007-05-11 03:36:16 · update #1

heres the mets stuff...

Reyes
Jose
SS
131
46
10
5
2
Beltran
Carlos
OF
120
40
9
2
7
Wright
David
3B
117
28
5
1
2
Green
Shawn
OF
114
40
9
0
4
Delgado
Carlos
1B
113
24
6
0
1
Alou
Moises
OF
92
32
7
0
2
LoDuca
Paul
C
90
24
1
0
2
Valentin
Jose
2B
68
19
5
1
2
Easley
Damion
2B
36
7
2
0
3
Chavez
Endy
OF
35
12
3
1
0
Castro
Ramon
C
34
8
0
0
3
Newhan
David
OF
18
2
0
0
0
Franco
Julio
1B
13
3
0
0
1
Milledge
Lastings
OF
3
0
0
0
0
Hernandez
Orlando
P
13
4
2
0
0

2007-05-11 03:39:28 · update #2

heres the yankees stuff....

Abreu
Bobby
OF
120
31
4
0
1
Jeter
Derek
SS
119
42
6
0
2
Rodriguez
Alex
3B
116
41
9
0
14
Cano
Robinson
2B
108
29
6
0
1
Giambi
Jason
DH
101
32
5
0
5
Cabrera
Melky
OF
95
22
1
1
0
Posada
Jorge
C
90
31
9
0
3
Damon
Johnny
OF
84
20
2
1
2
Mientkiewicz
Doug
1B
67
13
1
0
3
Matsui
Hideki
OF
52
14
5
0
2
Phelps
Josh
1B
31
9
1
0
1
Nieves
Wil
C
21
0
0
0
0
Cairo
Miguel
SS
13
2
0
0
0
Thompson
Kevin
OF
8
2
2
0
0
Rivera
Mariano
P
0
0
0
0
0



this for high school assignment and i really need help...plez....

2007-05-11 03:40:57 · update #3

3 answers

Do your own university assignment.

2007-05-11 03:37:19 · answer #1 · answered by Anonymous · 0 0

I recommend coffee. It helps you stay awake, and lets you deal with C++ lectures. I sure wish I knew about it back then.

But anyway, what you'll need to do is make a structure to hold the data.

struct idontwantotdomyownhomework {
char[40] strFirstName,
char[40] strLastName,
... etc
};

now make an array of them:

struc idontwantotdomyownhomework Players[MAX_PLAYERS];


Declare a counter, and start pulling in each line and grab the data from it with a while loop structure. http://www.cs.hmc.edu/~geoff/classes/hmc.cs070.200109/notes/io.html has a good tutorial on how to do input/output from a file. Put the data into the structure at the counter position.
Increment the counter, and end the loop.

The rest is easy math and itterating over an array of structures to get the stats.

2007-05-11 10:48:50 · answer #2 · answered by Enfold IT 2 · 0 0

Based on this link you just need to do your sums.
For each team
For each player
battingAverage=(hits+doubles+triples+homeRuns)/atBats
sluggingAverage=(hits+(2*doubles)+(3*triples)+(4*homeRuns))/atBats
totalAtBats=totalAtBats+atBats
totalHits=totalHits+hits
totalDoubles=totalDouble+doubles
totalTriples=totalTriples+triples
totalHomeRuns=totalHomeRuns+homeRuns
End For player
TotalBattingAverage=(totalHits+totalDoubles+totalTriples+totalHomeRuns)/totalAtBats
TotalSluggingAverage=(totalHits+(2*totalDoubles)+(3*totalTriples)+(4*totalHomeRuns))/totalAtBats
End For team

I am assuming that the hits value is the number of singles and not the total number of hits.

2007-05-11 10:59:51 · answer #3 · answered by AnalProgrammer 7 · 0 0

fedest.com, questions and answers