Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

When compiling this java file I\'m getting that I have 3 errors that I can\'t se

ID: 3606157 • Letter: W

Question

When compiling this java file I'm getting that I have 3 errors that I can't seem to fix. Hope you can help.

Error msg:

exec: javac -g HW9FacultyReport.java
HW9FacultyReport.java:132: error: cannot find symbol
avgStuds = totstuds / facCount;
^
symbol: variable totstuds
location: class FacultyReport
HW9FacultyReport.java:142: error: cannot find symbol
System.out.print("Total Sections:" + totsects );
^
symbol: variable totsects
location: class FacultyReport
HW9FacultyReport.java:143: error: cannot find symbol
System.out.print("Total Studens:"+ totstuds);
^
symbol: variable totstuds
location: class FacultyReport
3 errors

Source code java:

/*

Problem: Homework9

*/

import java.io.*;

public class HW9FacultyReport

{

public static void main(String args[]) throws IOException

{

FacultyReport app;

app = new FacultyReport();

app.appMain();

}

}

class FacultyReport

{

// Data (Field) Declaration, so declare all your variables HERE

BufferedReader stdin; // stdin will represent the keyboard

int term; //the school term being reported

int facultyID; //the faculty id number

int sections; //number of sections taught by a faculty member

int students; //number of students taught by a faculty member

int totSects; //total number of sections taught

int totStuds; //total number students taught

int avgStuds; //average number of students (total students / number of faculty)

int hiStuds; //highest number of students taught

int facCount; //number of faculty

int hiFac; //faculty id of who taught the highest number of students

  

// appMain is analogous to your Pseudocode Main

void appMain() throws IOException

{

  

System.out.print("Input Term: ");

term = Integer.parseInt(stdin.readLine());

System.out.print("Term ");

initVars();

// call other methods and loop as needed

{

while (facultyID > -1);

{

ProcFaculty();

System.out.print("Input Faculty ID: ");

}

CalcAvg();

DisplaySummary();

  

}  

}

void initVars()

{

// create standard input object to connect to the keyboard

stdin = new BufferedReader(new InputStreamReader(System.in));

// Initialize working storage type variables/fields HERE  

facCount = totSects = totStuds = hiStuds = 0;   

}

void ProcFaculty()throws IOException

{

GetDetails();

CalcTotals();

Update();

DisplayFacDetails();

}

  

void GetDetails()

{

System.out.print("Input Sections: ");

sections = Integer.parseInt(stdin.readLine());

System.out.print("Input Students: ");

students = Integer.parseInt(stdin.readLine());

  

}

void CalcTotals()

{

facCount = facCount + 1;

totSects = totSects + sections;

totStuds = totStuds + students;

  

  

}

  

  

void Update()

{

if (students > hiStuds);

{

hiStuds = students;

hiFac = facultyID;

}

  

}

  

  

void DisplayFacDetails()

{

System.out.print("Faculty ID: ");

System.out.print("Sections: ");

System.out.print("Students: ");

}

  

  

void CalcAvg()

{

avgStuds = totstuds / facCount;

  

}

void DisplaySummary()

{

System.out.print("Total Sections:" + totsects );

System.out.print("Total Studens:"+ totstuds);

System.out.print("Average Students:"+ avgStuds);

System.out.print("Highest Number of Students: "+ hiStuds);

System.out.print("Faculty ID of Highest number of Students taught: "+ hiFac);   

}

}

  

Explanation / Answer

Hi.. I have modified the code and it is running fine. Please check the below code.

HW9FacultyReport.java

import java.io.*;

public class HW9FacultyReport

{

public static void main(String args[]) throws IOException

{

FacultyReport app;

app = new FacultyReport();

app.appMain();

}

}

class FacultyReport

{

// Data (Field) Declaration, so declare all your variables HERE

BufferedReader stdin; // stdin will represent the keyboard

int term; //the school term being reported

String facultyID; //the faculty id number

int sections; //number of sections taught by a faculty member

int students; //number of students taught by a faculty member

int totSects; //total number of sections taught

int totStuds; //total number students taught

int avgStuds; //average number of students (total students / number of faculty)

int hiStuds; //highest number of students taught

String hiFac; //faculty id of who taught the highest number of students

int facCount;

// appMain is analogous to your Pseudocode Main

void appMain() throws IOException

{

initVars();

System.out.print("Input Term: ");

term = Integer.parseInt(stdin.readLine());

System.out.println("Term :"+term);

System.out.print("Input Faculty ID: ");

facultyID = stdin.readLine();

// call other methods and loop as needed

//While (facultyID > -1);

ProcFaculty();

CalcAvg();

DisplaySummary();

}

void initVars()

{

// create standard input object to connect to the keyboard

stdin = new BufferedReader(new InputStreamReader(System.in));

// Initialize working storage type variables/fields HERE

facCount = totSects = totStuds = hiStuds = 0;

}

void ProcFaculty()throws IOException

{

GetDetails();

CalcTotals();

Update();

DisplayFacDetails();

}

void GetDetails() throws NumberFormatException, IOException

{

System.out.print("Input Sections: ");

sections = Integer.parseInt(stdin.readLine());

System.out.print("Input Students: ");

students = Integer.parseInt(stdin.readLine());

}

void CalcTotals()

{

facCount = facCount + 1;

totSects = totSects + sections;

totStuds = totStuds + students;

}

void Update()

{

if (students > hiStuds)

{

hiStuds = students;

hiFac = facultyID;

}

}

void DisplayFacDetails()

{

System.out.println("Display Faculty Details");

System.out.println("Faculty ID: "+hiFac);

System.out.println("Sections: "+totSects);

System.out.println("Students: "+totStuds);

}

void CalcAvg()

{

avgStuds = totStuds / facCount;

}

void DisplaySummary()

{

System.out.println("Display Summary Details");

System.out.println("Total Sections:" + totSects );

System.out.println("Total Studens:"+ totStuds);

System.out.println("Average Students:"+ avgStuds);

System.out.println("Highest Number of Students: "+ hiStuds);

System.out.println("Faculty ID of Highest number of Students taught: "+ hiFac);

}

}

Output:

Input Term: 10

Term :10

Input Faculty ID: Priya

Input Sections: 10

Input Students: 100

Display Faculty Details

Faculty ID: Priya

Sections: 10

Students: 100

Display Summary Details

Total Sections:10

Total Studens:100

Average Students:100

Highest Number of Students: 100

Faculty ID of Highest number of Students taught: Priya

Please check once and let me know if you have any queries. Thank you. All the best.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote