How to calculate average especially when reading a file


How to calculate average especially when reading a file like how to create a method for average the years of service between three employees like e1.getYears + e2.getYears+e3.getYears/3

public static void main(String [] args) throws IOException
{
Employee e1 = new Employee();
Employee e2 = new Employee();
Employee e3 = new Employee();


// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);

// Get the filename.

String filename = keyboard.nextLine();

// Open the file.
File file = new File("employees.txt");
Scanner inputFile = new Scanner(file);

// Read lines from the file until no more are left.
while (inputFile.hasNext())
{
// Read the next name.
String line = inputFile.nextLine();

// Display the last name read.
System.out.println(line);
}

System.out.println("average is");

// Close the file.
inputFile.close();
}

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: How to calculate average especially when reading a file
Reference No:- TGS0128609

Expected delivery within 24 Hours