Hello,

I recently started a project for my intro to Java course.The project is to create an app that calculates a baseball player's batting average and slugging percentage(many of you have likely heard of this project before). Here are the details for the application:

"This application calculates the batting average and slugging percentage for one or more baseball or softball players.

For each player, the application first asks for the number of at bats. Then, for each at bat, the application asks for the result.

After all the at-bat results are entered, the application displays the batting average and slugging percent.

The batting average is the total number of at bats for which the player earned at least one base divided by the number of at bats.

The slugging percentage is the total number of bases earned divided by the number of at bats.

Use an array to store the at-bat results for a player.

Validate the input so the user can enter only positive integers. For the at-bat results, the user’s entry must be 0, 1, 2, 3, or 4.

Validate the user’s response to the question “Another batter?” so the user can enter only Y, y, N, or n. If the user enters Y or y, calculate the statistics for another batter. Otherwise, end the program."

I only used one class with the different methods to accomplish this. Here is my pseudo code:

BattingAverage Class

MAIN:

Code :

PRINT “Welcome to the Batting Average calculator.” DO numberAtBats = getNumberAtBats() PRINT “0 = out, 1 = single, 2 = double, 3 = triple, 4 = home run” Int[] results array = new int[numberAtBats] \\ use numberAtBats as size of results array FOR each position(numberAtBats) of batResults array IF batResult > 0 THEN ADD 1 to totalBatsWithBase ADD batResults to totalBasesEarned Compute battingAverage as totalBatsWithBase / numberAtBats Compute sluggingPercentage as totalBasesEarned / numberAtBats PRINT battingAverage and slugging Percentage WHILE getAnotherBatter() getNumberAtBats: WHILE input is invalid PRINT “Enter number of times at bat: “ IF input is an integer input = numberAtBats If numAtBats > 0; input is valid ENDWHILE RETURN numberAtBats getBatResults: WHILE input is invalid PRINT “Result for at-bat: “ IF input is an integer input = batResults IF batResults = 0-4 Input is valid RETURN batResults getAnotherBatter: PRINT “Another batter?” IF choice = y RETURN true // start over ELSE RETURN false //End

My problem is that the teacher said I need more than one class. I'm not sure why, as I believe this should function as is, but his response was this:

"You have one class where you need at least two. getAnotherBatter is a hint that your class is mixing two classes."

So my question iswhy do I need more than one class?Have I left something out?

Can anyone help me understand how I am mixing two classes, and why it will not work as one?

He mentioned that getAnotherBatter is a hint that I am mixing two classes, but I'm having trouble figuring out how.

Thanks for your time, and I appreciate any help!