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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 5PE
icon
Related questions
Question

hello! can you help me debug my program? here are the errors I'm getting:

line 126: the method newFantasyFootball is undefined for the type FantasyFootball
line 127: the method enterInData is undefined for the type FantasyFootball

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
Transcribed Image Text: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<numberofWeeks)
92
93
94
95
System.out.print("Team"+(i+1));
System.out.print('\t');
i++;
System.out.println();
i=0;
while(i<number0fTeams)
{
System.out.print (teamName [i]);
System.out.print ('\t');
j=0;
while(j<number0fWeeks)
{
System.out.print (scores [i]);
System.out.println();
i+t;
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
j=0;
System.out.print ("Weekly Avg");;
System.out.print ('\t');;
while(j<number0fWeeks)
112
113
114
115
116
117
118
System.out.print((int)weekAverage [j]);
System.out.print('\t');;
j++;
119
120
121
122
123
124
125
126
127
128
public static void maind (String[] args)
FantasyFootball f= newFantasyFootball();
f.enterInData();
f.fillTeamAverage ();
f.fillweekAverage ();
129
130
131
f.display();
132
133
Transcribed Image Text:System.out.print('\t'); int i=0, j=0; while(i<numberofWeeks) 92 93 94 95 System.out.print("Team"+(i+1)); System.out.print('\t'); i++; System.out.println(); i=0; while(i<number0fTeams) { System.out.print (teamName [i]); System.out.print ('\t'); j=0; while(j<number0fWeeks) { System.out.print (scores [i]); System.out.println(); i+t; 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 j=0; System.out.print ("Weekly Avg");; System.out.print ('\t');; while(j<number0fWeeks) 112 113 114 115 116 117 118 System.out.print((int)weekAverage [j]); System.out.print('\t');; j++; 119 120 121 122 123 124 125 126 127 128 public static void maind (String[] args) FantasyFootball f= newFantasyFootball(); f.enterInData(); f.fillTeamAverage (); f.fillweekAverage (); 129 130 131 f.display(); 132 133
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT