Question
I am trying to create the following language in the Java language. I specifically need to be able to fill out a report using arrays
I am trying to create the following language in the Java language. I specifically need to be able to fill out a report using arrays and then answer a few questions using methods. Those are the main criteria for this that HAVE to happen. The problem is below in bold. I will attach my code below it.
Problem:
Create a Java program to store the team standings for a NCAA MAC Conference game of your choice. Example: Last years mid-season, in-conference games played by the MAC (Mid-American Conference) NCAA football teams, utilizing the following 6 parallel arrays:
college, teamName, state, div, win, loss
Create the parallel arrays with the appropriate data types
Populate the arrays with the following data:
| College | Team Name | State | Division | Win | Loss |
0 | Akron | Zips | OH | E | 3 | 4 |
1 | Ball State | Cardinals | IN | W | 1 | 5 |
2 | Bowling Green | Falcons | OH | E | 1 | 5 |
3 | Buffalo | Bulls | NY | E | 1 | 5 |
4 | Central Michigan | Chippewas | MI | W | 2 | 4 |
5 | Eastern Michigan | Eagles | MI | W | 3 | 3 |
6 | Kent State | Golden Flashes | OH | E | 2 | 4 |
7 | Miami | RedHawks | OH | E | 5 | 2 |
8 | Northern Illinois | Huskies | IL | W | 3 | 3 |
9 | Ohio | Bobcats | OH | E | 5 | 1 |
10 | Toledo | Rockets | OH | W | 5 | 1 |
11 | UMass | Minutemen | MA | E | 0 | 4 |
12 | Western Michigan | Broncos | MI | W | 6 | 0 |
Output:
Generate a report of the entire data set as shown above, formatted into 7 columns, adding a calculated column (the 7th column) with the win percentage (wins/total games) stored in a variable winPct.
College Team Name State Division Win Loss Win %
Then, use methods and the same report format to generate 6 reports as follows. Create additional functions where you pass the array and any other parameter(s).
Display only the teams from MI
Display only the teams from OH
Display only the teams whose state starts with some letter of your choice
Display only the West division teams
Display the teams with exactly 3 wins
Display the team with the highest win percentage (find max of winPct)
This will require repeating the looping statement to generate the first list 4 more times, but using an if statement within the loop to determine whether or not to print the team based on the criteria above.
My code:
public class TeamStandings
{
public static void main(String[] args)
{
//variables/arrays
String university[] = {"Akron", "Ball State", "Bowling Green", "Buffalo", "Central Michigan", "Eastern Michigan",
"Kent State", "Miami", "Northern Illinois", "Ohio", "Toledo", "UMass", "Western Michigan"};
String teamName[] = {"Zips", "Cardinals", "Falcons", "Bulls", "Chippewas", "Eagles",
"Golden Flashes", "RedHawks", "Huskies", "Bobcats", "Rockets", "Minutemen", "Broncos"};
String state[] = {"OH", "IN", "OH", "NY", "MI", "MI", "OH", "OH","IL", "OH", "OH","MA","MI"};
char div[] = {'E', 'W', 'E', 'E', 'W', 'W','E', 'E', 'W', 'E', 'W', 'E', 'W'};
int wins[] = {3, 1, 1, 1, 2, 3, 2, 5, 3, 5, 5, 0, 6};
int loss[] = {4, 5, 5, 5, 4, 3, 4, 2, 3, 1, 1, 4, 0};
double winPercentage[] = new double[wins.length];
/*determine win percent
MAKE INTO A METHOD?*/
for(int i = 0; i < wins.length; i++)
winPercentage[i] = wins[i] * 100.0 / (wins[i] + loss[i]);
//report generated
System.out.println("Report:");
//header
System.out.format(" %-20s%-20s%-20s%-20s%-20s%-20s%-20s", "University", "Team Name", "State", "Division", "Win", "Loss", "Win Percent");
//for loop -- fill data
for(int i = 0; i < university.length; i++);
{
System.out.format("%-30s %-20s %-10s %-10c%-10d%-10d%-10.2f", university[i], teamName[i], state[i], div[i], wins[i], loss[i], winPercentage[i]);
}
}
}
*****I'm receiving an error on my i in the last "System.out.format()" saying it cannot be resolved as a variable but I have no idea why.*****
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started