1. package fantasyFootball; 2 import java.util.Scanner; 4 public class FantasyFootball { private int numberofTeams; //same as teamAverage. length private int numberofWeeks; //same as weekAverage.lenght private int[[] scores; //number of teams rows & number of weeks columns private double[] weekAverage; // contains an entry for each week private double[] teamAverage; // contains an entry for each team private String [] teamName; // contains an entry for each team 6. 8. 9. 10 11 12 13 14- public void enterInDate ( 15 16 Scanner keyboard = new Scanner(System.in); System.out.println ("Enter number of team:"); numberofTeams = keyboard.nextInt(); 17 18 19 20 System.out.println ("Enter number of weeks:"); numberofWeeks = keyboard.nextInt(); 21 22 //String teamName []=new String [number0fTeams]; //int scores[][]=new int [number0fTeams] [number0fWeeks]; 23 24 25 //allocate array memory for teamName to store the team names //allocate array memory for scores (2-d array) to store a //score for each team for each week 26 27 28 29 for (int team = 0; team < numberofTeams; team++) { System.out.println("Enter team name"); 30 31 32 33 34 //Read in team name and store it in TeamName 35 String name=keyboard.nextLine (); teamName [team]=name; for (int week = 0; week < number0fWeeks; week++) 36 37 38 39 System.out.println("Enter score for team "+teamName [team]); System.out.println("on week number "+(week+1)); //read in a score and store it in the proper spot in the scores array int score=keyboard.nextInt(); scores[team] [week]=score; 40 42 43 44 45 46 47 48 - public void fillTeamAverage() 49 //allocate memory for the teamAverage //each entry in this array will contain the //average weekly score for a given team //double teamAverage[]=new double [number0fTeams] for (int team=0; team < number0fTeams; team++) 50 51 52 53 54 55 int sum=0; double average=0.0; for (int week =0; week < numberofWeeks; week++) 56 57 58 59 sum=sum+scores [team] [week]; 60 61 average=sum/number0fWeeks; teamAverage [team]=average; 62 63 64 65 66 - 67 68 public void fillweekAverage() //Allocate memory for the weekAverage instance variable //each entry in this array will contain the average of //all teams for a given week 69 70 71 72 //double weekAverage []=new double [number0fTeams]; 73 74 for (int week = 0; week < numberofWeeks; week++) 75 int sum = 0; double average = 0.0; for (int team = 0; team < numberofTeams; team++) 76 77 78 79 80 sum = sum + scores [team] [week]; 81 82 83 84 average=sum/number0fTeams; weekAverage [number0fWeeks]=average; 85 86 - 87 public void display() //this method will print out the display that was shown above //at this point all of the information can be found in the //private instance variables of the FantasyFootball class System.out.print ("Team Name"); 88 89 90 91 System.out.print('\t'); int i=0, j=0; while(i
1. package fantasyFootball; 2 import java.util.Scanner; 4 public class FantasyFootball { private int numberofTeams; //same as teamAverage. length private int numberofWeeks; //same as weekAverage.lenght private int[[] scores; //number of teams rows & number of weeks columns private double[] weekAverage; // contains an entry for each week private double[] teamAverage; // contains an entry for each team private String [] teamName; // contains an entry for each team 6. 8. 9. 10 11 12 13 14- public void enterInDate ( 15 16 Scanner keyboard = new Scanner(System.in); System.out.println ("Enter number of team:"); numberofTeams = keyboard.nextInt(); 17 18 19 20 System.out.println ("Enter number of weeks:"); numberofWeeks = keyboard.nextInt(); 21 22 //String teamName []=new String [number0fTeams]; //int scores[][]=new int [number0fTeams] [number0fWeeks]; 23 24 25 //allocate array memory for teamName to store the team names //allocate array memory for scores (2-d array) to store a //score for each team for each week 26 27 28 29 for (int team = 0; team < numberofTeams; team++) { System.out.println("Enter team name"); 30 31 32 33 34 //Read in team name and store it in TeamName 35 String name=keyboard.nextLine (); teamName [team]=name; for (int week = 0; week < number0fWeeks; week++) 36 37 38 39 System.out.println("Enter score for team "+teamName [team]); System.out.println("on week number "+(week+1)); //read in a score and store it in the proper spot in the scores array int score=keyboard.nextInt(); scores[team] [week]=score; 40 42 43 44 45 46 47 48 - public void fillTeamAverage() 49 //allocate memory for the teamAverage //each entry in this array will contain the //average weekly score for a given team //double teamAverage[]=new double [number0fTeams] for (int team=0; team < number0fTeams; team++) 50 51 52 53 54 55 int sum=0; double average=0.0; for (int week =0; week < numberofWeeks; week++) 56 57 58 59 sum=sum+scores [team] [week]; 60 61 average=sum/number0fWeeks; teamAverage [team]=average; 62 63 64 65 66 - 67 68 public void fillweekAverage() //Allocate memory for the weekAverage instance variable //each entry in this array will contain the average of //all teams for a given week 69 70 71 72 //double weekAverage []=new double [number0fTeams]; 73 74 for (int week = 0; week < numberofWeeks; week++) 75 int sum = 0; double average = 0.0; for (int team = 0; team < numberofTeams; team++) 76 77 78 79 80 sum = sum + scores [team] [week]; 81 82 83 84 average=sum/number0fTeams; weekAverage [number0fWeeks]=average; 85 86 - 87 public void display() //this method will print out the display that was shown above //at this point all of the information can be found in the //private instance variables of the FantasyFootball class System.out.print ("Team Name"); 88 89 90 91 System.out.print('\t'); int i=0, j=0; while(i
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 5PE
Related questions
Question
hello! can you help me debug my
line 126: the method newFantasyFootball is undefined for the type FantasyFootball
line 127: the method enterInData is undefined for the type FantasyFootball
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT