Write a program that collects an input filename and an output filename. The inpu
ID: 3655703 • Letter: W
Question
Write a program that collects an input filename and an output filename. The input file contains lines with two double numbers per line. Write the maximum of each line in the input file to the output file (one average per line). Use a Scanner to collect the filenames from the user. Test your program using numbers.txt for input.
Modify your program so that it prints the maximum of each line even if there are not
exactly two numbers on each line of the input file. Assume there is at least one number per line.
Test using moreNumbers.txt.
Explanation / Answer
import java.io.*; import java.text.NumberFormat; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * General purpose utilities functions. * * @author Colin Bell */ public class Utilities { /** * Return the suffix of the passed file name. * * @param fileName File name to retrieve suffix for. * * @return Suffix for fileName or an empty string * if unable to get the suffix. * * @throws IllegalArgumentException if null file name passed. */ public static String getFileNameSuffix(String fileName) { if (fileName == null) { throw new IllegalArgumentException("file name == null"); } int pos = fileName.lastIndexOf('.'); if (pos > 0 && posRelated 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.