Question: Write the following program in JAVA: Write a class called NameMethods which contains the following instance variable and methods: Instance Variable: AvgLength- an integer preset
Write the following program in JAVA: Write a class called NameMethods which contains the following instance variable and methods: Instance Variable: AvgLength- an integer preset to 0 Methods: ReadNames: Given no values from the main method (i.e. no parameters), create a String array called names, read 50 names from a file called "names1.txt" into the array and return the array to the main method AvgCalc: Given a String array from the MAIN METHOD, determine the average length of the names in the array. Store the average in the instance variable AvgLength. Do NOT return its value to the main method. FindNames: Given a String array and a single letter from the main method, determine which friends have a name either starting or ending with that letter. (Remember to deal with case sensitivity.) Write every name matching this criteria to a file called "names2.txt". Do not output any values on screen and do not return any values to the main method. You may declare any extra variables needed inside the methods.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
