Name: 5 pts) Write a complete program that reads midterm scores from a file name
ID: 3146736 • Letter: N
Question
Name: 5 pts) Write a complete program that reads midterm scores from a file named midterm.txt. The program should find, and then print the largest and smallest scores in the file. The file named midterm.txt contains one integer score per line, and always contains at least two scores. All integer scores are greater than or than or equal to 100. Hint: You will need variables to store the largest and smallest scores. After reading each number, update the variables for the largest and smallest scores as needed. You will need to read all the integers from the file with no knowledge of how many there will be. equal to 0 and less Example File: The following is the content of an example file that your program should work with: 45 78 89 32 94 Example Output: The output for running your code against the above example fil would look something like this: Highest Score is 94 Lowest Score is 3:2Explanation / Answer
import java.util.*; import java.io.*; Class Abc { public static void main(String args[]) { File fin=midterm; } } private static void readFile1(File fin) throws IOException { Int max=0,min=101; FileInputStream fis = new FileInputStream(fin); BufferedReader br = new BufferedReader(new InputStreamReader(fis)); String line = null; while ((line = br.readLine()) != null) { int k=Integer.parseInt(line); if(k>max) max=k; if(kRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.