Question
How do i pass my michiganTeam method to my main method to display? Any help would be greatly appreciated. The language is Java My code:
How do i pass my michiganTeam method to my main method to display? Any help would be greatly appreciated. The language is Java
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");
System.out.format(" %-20s%-20s%-20s%-20s%-20s%-20s%-20s", "----------", "---------", "-----", "--------", "---", "----", "-----------");
//for loop -- fill data
for(int i = 0; i < university.length; i++)
{
System.out.format(" %-20s%-20s%-20s%-20c%-20d%-20d%-20.2f", university[i], teamName[i], state[i], div[i], wins[i], loss[i], winPercentage[i]);
}
//display
michiganTeam();
}
//teams from Michigan (method)
public static void michiganTeam(String st, String university[], String state[], String teamName[], char div[], int wins[], int loss[], double winPercentage[])
{
//divider & header
System.out.format(" %-20s%-20s%-20s%-20s%-20s%-20s%-20s", "----------", "---------", "-----", "--------", "---", "----", "-----------");
System.out.println("Teams from Michigan:");
//header
System.out.format(" %-20s%-20s%-20s%-20s%-20s%-20s%-20s", "University", "Team Name", "State", "Division", "Win", "Loss", "Win Percent");
for(int i = 0; i < university.length; i++)
{
if (state[i].equals("MI"))
{
System.out.format(" %-20s%-20s%-20s%-20c%-20d%-20d%-20.2f", university[i], teamName[i], state[i], div[i], wins[i], loss[i], winPercentage[i]);
}
}
//teams from Ohio (method)
//teams from state letter of choice (method)
//teams from west division (method)
//teams with 3 wins (method)
//team with highest win percentage (method)
}
}
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