Question: Please write a Java class that takes a text file as input, and is able to calculate the average, minimum and maximum values for one

Please write a Java class that takes a text file as input, and is able to calculate the average, minimum and maximum values for one column in that input text file. You should print out the average, minimum and maximum values of that data to a text file.

I can't upload my txt file but if you can make a txt file on your computer called Expenditure.txt with the following data

Jan,108 Feb,167 March,104 April,132 May,201 June,177 July,185 August,150 September,103 October,114 November,121 December,145

Here are some notes from class:

import java.io.*; import java.util.*; public class OutputFile { public static void main(String[] args) { try { double avg = 3.4; double min = 1.2; double max = 5.4; PrintWriter writer = new PrintWriter(new FileWriter("out.txt")); writer.println("Here is the average of my data: "+ avg); writer.println("Here is the min of my data: "+ min); writer.println("Here is the max of my data: "+ max); writer.close(); } catch (IOException e) { System.out.println("Oops. Java could not push my data to the file"); e.printStackTrace(); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!