Create a Java program to store the team standings for a NCAA MAC Conference game
ID: 3849281 • Letter: C
Question
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: Output: 1. Generate a report of the entire data set as shown above, formatted into 7 columns, adding a calculated column (the 7^th 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). 2. Display only the teams from MI 3. Display only the teams from OH 4. Display only the teams whose state starts with some letter of your choice 5. Display only the West division teams 6. Display the teams with exactly 3 wins 7. 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.Explanation / Answer
//packages
import java.util.Scanner;
public class Tournment{
Team teams[];
public Tournment(){
teams=new Team[13];
teams[0]=new Team("Akron","Zips","OH",'E',3,4);
teams[1]=new Team("Ball State","Cardinals","IN",'W',1,5);
teams[2]=new Team("Bowlling Green","Falcons","OH",'E',1,5);
teams[3]=new Team("Buffalo","Bulls","NY",'E',1,5);
teams[4]=new Team("Central Michigan","Chippewas","MI",'W',2,4);
teams[5]=new Team("Eastren Michigan","Eagles","MI",'W',3,3);
teams[6]=new Team("Kent State","Golden Flashes","OH",'E',2,4);
teams[7]=new Team("Miami","RedHawks","OH",'E',5,2);
teams[8]=new Team("Northern Illinois","Huskies","IL",'W',3,3);
teams[9]=new Team("Ohio","Bobcats","OH",'E',5,1);
teams[10]=new Team("Toledo","Zips","OH",'W',5,1);
teams[11]=new Team("UMass","Zips","OH",'E',0,4);
teams[12]=new Team("Westren Michigan","Zips","OH",'W',6,0);
Scanner sc=new Scanner(System.in);
int option;
while(true){
menu();
System.out.print("Enter ur option::");
option=sc.nextInt();
if(option==0){
break;
}
switch(option){
case 1:
generateReport();break;
case 2:
dipslayFromMI();break;
case 3:
dipslayFromOH();break;
case 4:
dipslayOnChoice();break;
case 5:
dipslay3Wins();break;
case 6:
MaxPec();break;
}
}
}
public void menu(){
String m="1->Generate a report of the entire data set formeted into 7 columns,adding a calcuated with the win percentage "+
"2->Display only team from MI "+
"3->Display only teams from OH "+
"4->Display only teams whose states starting with some letter of your choice "+
"5->Display Teams with Exactly 3 wins "+
"6->Display the teams with highest win percentage "+
"0->Exit";
System.out.println(m);
}
//1->Generate a report of the entire data set formeted into 7 columns,adding a calcuated with the win percentage
public void generateReport(){
for(int i=0;i<teams.length;i++){
System.out.println(teams[i]);
}
}
//"2->Display only team from MI"
public void dipslayFromMI(){
for(int i=0;i<teams.length;i++){
if(teams[i].getState().equals("MI")){
System.out.println(teams[i]);
}
}
}
//"2->Display only team from OH"
public void dipslayFromOH(){
for(int i=0;i<teams.length;i++){
if(teams[i].getState().equals("OH")){
System.out.println(teams[i]);
}
}
}
//4->Display only teams whose states starting with some letter of your choice "
public void dipslayOnChoice(){
Scanner sc=new Scanner(System.in);
System.out.print("Enter a charecter::");
char c=sc.next().toUpperCase().charAt(0);
for(int i=0;i<teams.length;i++){
if(teams[i].getState().charAt(0)==c){
System.out.println(teams[i]);
}
}
}
//5->Display Teams with Exactly 3 wins
public void dipslay3Wins(){
for(int i=0;i<teams.length;i++){
if(teams[i].getWins()==3){
System.out.println(teams[i]);
}
}
}
//5->Display Teams with Exactly 3 wins
public void MaxPec(){
int pos=0;
double mx=teams[pos].getWinPct();
for(int i=0;i<teams.length;i++){
if(teams[i].getWinPct()>mx){
mx=teams[i].getWinPct();
pos=i;
}
}
System.out.println(teams[pos]);
}
public static void main(String args[]){
new Tournment();
}
}
//Team class
class Team{
private String college,teamName,state;
char division;
private int win,loss;
private double winpct;
public Team(String college,String teamName,String state,char division,int win,int loss){
this.college=college;
this.teamName=teamName;
this.state=state;
this.division=division;
this.win=win;
this.loss=loss;
this.winpct=(win*1.0f)/(win+loss);
this.winpct=Double.parseDouble(String.format( "%.2f",winpct));
}
//toString method
public String toString(){
return String.format("%-25s",this.college)+" "+ String.format("%-10s",this.teamName)+" "+this.state+" "+this.division
+" "+this.win+" "+this.loss+" "+this.winpct;
}
public String getTeamName(){
return this.teamName;
}
public String getState(){
return this.state;
}
public double getWinPct(){
return this.winpct;
}
public char getDivision(){
return this.division;
}
public int getWins(){
return this.win;
}
}