I am trying to create the following language in the Java language. I specificall
ID: 3850107 • Letter: I
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 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 year’s 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.*****
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
Explanation / Answer
public class FBTeamReport {
public static void main(String[] args) {
String college[] = {"Akron", "Ball State", "Bowling Green", "Buffalo", "Central Michigan",
"Eastern Michigan", "Kent State", "Miami", "Northern Illinois", "Ohio",
"Toledo", "UMass", "Western Michigan"};
String team[] = {"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 division[]={'E', 'W', 'E', 'E', 'W',
'W','E', 'E', 'W', 'E',
'W', 'E', 'W'};
int win[] = {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 winPct[] = new double[win.length];
for(int i = 0; i < win.length; i++)
winPct[i] = win[i] * 100.0 / (win[i] + loss[i]);
System.out.println("_______________________________");
System.out.println("All teams");
System.out.println("_______________________________");
System.out.printf(" %-30s %-20s %-10s %-10s %10s %10s %10s", "College", "Team", "State", "Division", "Win", "Loss", "Win %");
for(int i = 0; i < college.length; i++ )
{
System.out.printf(" %-30s %-20s %-10s %-10c %10d %10d %10.2f", college[i], team[i], state[i], division[i], win[i], loss[i], winPct[i]);
}
System.out.println(" _______________________________");
System.out.println("Teams from MI");
System.out.println("_______________________________");
System.out.printf(" %-30s %-20s %-10s %-10s %10s %10s %10s", "College", "Team", "State", "Division", "Win", "Loss", "Win %");
for(int i = 0; i < college.length; i++ )
{
if(state[i].equals("MI"))
System.out.printf(" %-30s %-20s %-10s %-10c %10d %10d %10.2f", college[i], team[i], state[i], division[i], win[i], loss[i], winPct[i]);
}
System.out.println(" _______________________________");
System.out.println("Teams from OH");
System.out.println("_______________________________");
System.out.printf(" %-30s %-20s %-10s %-10s %10s %10s %10s", "College", "Team", "State", "Division", "Win", "Loss", "Win %");
for(int i = 0; i < college.length; i++ )
{
if(state[i].equals("OH"))
System.out.printf(" %-30s %-20s %-10s %-10c %10d %10d %10.2f", college[i], team[i], state[i], division[i], win[i], loss[i], winPct[i]);
}
System.out.println(" _______________________________");
System.out.println("Teams from state with I");
System.out.println("_______________________________");
System.out.printf("%-30s %-20s %-10s %-10s %10s %10s %10s", "College", "Team", "State", "Division", "Win", "Loss", "Win %");
for(int i = 0; i < college.length; i++ )
{
if(state[i].startsWith("I"))
System.out.printf(" %-30s %-20s %-10s %-10c %10d %10d %10.2f", college[i], team[i], state[i], division[i], win[i], loss[i], winPct[i]);
}
System.out.println(" _______________________________");
System.out.println("Western division teams");
System.out.println("_______________________________");
System.out.printf("%-30s %-20s %-10s %-10s %10s %10s %10s", "College", "Team", "State", "Division", "Win", "Loss", "Win %");
for(int i = 0; i < college.length; i++ )
{
if(division[i] == 'W')
System.out.printf(" %-30s %-20s %-10s %-10c %10d %10d %10.2f", college[i], team[i], state[i], division[i], win[i], loss[i], winPct[i]);
}
System.out.println(" _______________________________");
System.out.println("Teams with exactly 3 Wins");
System.out.println("_______________________________");
System.out.printf("%-30s %-20s %-10s %-10s %10s %10s %10s", "College", "Team", "State", "Division", "Win", "Loss", "Win %");
for(int i = 0; i < college.length; i++ )
{
if(win[i] == 3)
System.out.printf(" %-30s %-20s %-10s %-10c %10d %10d %10.2f", college[i], team[i], state[i], division[i], win[i], loss[i], winPct[i]);
}
//find team with highest winPct
int idx = 0;
for(int i = 1; i < winPct.length; i++)
{
if(winPct[i] > winPct[idx])
idx = i;
}
System.out.println(" _______________________________");
System.out.println("Team with hightest win % is ");
System.out.println("_______________________________");
System.out.printf(" %-30s %-20s %-10s %-10c %10d %10d %10.2f", college[idx], team[idx], state[idx], division[idx], win[idx], loss[idx], winPct[idx]);
}
}
output
_______________________________
All teams
_______________________________
College Team State Division Win Loss Win %
Akron Zips OH E 3 4 42.86
Ball State Cardinals IN W 1 5 16.67
Bowling Green Falcons OH E 1 5 16.67
Buffalo Bulls NY E 1 5 16.67
Central Michigan Chippewas MI W 2 4 33.33
Eastern Michigan Eagles MI W 3 3 50.00
Kent State Golden Flashes OH E 2 4 33.33
Miami RedHawks OH E 5 2 71.43
Northern Illinois Huskies IL W 3 3 50.00
Ohio Bobcats OH E 5 1 83.33
Toledo Rockets OH W 5 1 83.33
UMass Minutemen MA E 0 4 0.00
Western Michigan Broncos MI W 6 0 100.00
_______________________________
Teams from MI
_______________________________
College Team State Division Win Loss Win %
Central Michigan Chippewas MI W 2 4 33.33
Eastern Michigan Eagles MI W 3 3 50.00
Western Michigan Broncos MI W 6 0 100.00
_______________________________
Teams from OH
_______________________________
College Team State Division Win Loss Win %
Akron Zips OH E 3 4 42.86
Bowling Green Falcons OH E 1 5 16.67
Kent State Golden Flashes OH E 2 4 33.33
Miami RedHawks OH E 5 2 71.43
Ohio Bobcats OH E 5 1 83.33
Toledo Rockets OH W 5 1 83.33
_______________________________
Teams from state with I
_______________________________
College Team State Division Win Loss Win %
Ball State Cardinals IN W 1 5 16.67
Northern Illinois Huskies IL W 3 3 50.00
_______________________________
Western division teams
_______________________________
College Team State Division Win Loss Win %
Ball State Cardinals IN W 1 5 16.67
Central Michigan Chippewas MI W 2 4 33.33
Eastern Michigan Eagles MI W 3 3 50.00
Northern Illinois Huskies IL W 3 3 50.00
Toledo Rockets OH W 5 1 83.33
Western Michigan Broncos MI W 6 0 100.00
_______________________________
Teams with exactly 3 Wins
_______________________________
College Team State Division Win Loss Win %
Akron Zips OH E 3 4 42.86
Eastern Michigan Eagles MI W 3 3 50.00
Northern Illinois Huskies IL W 3 3 50.00
_______________________________
Team with hightest win % is
_______________________________
Western Michigan Broncos MI W 6 0 100.00
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.