Question: Write a program in Java which accepts an input text file containing words, saves it to an array, sorts the array according to the first

Write a program in Java which accepts an input text file containing words, saves it to an array, sorts the array according to the first letter and outputs to the standard output. In order to sort, you must use the Insertion Sort (no other type of sorting is permitted). It is assumed that words in the input text file are separated by commas. The name of the Java class must be StringSorter which implements the interface Sorter. The program must throw a RuntimeException if a word does not start with a letter, displaying the following message: Word found which does not start with a letter. To test if a character is a letter or not, you may use the method Character.isLetter().

you are not allowed to use any existing Java library and/or external packages for solving the problem.

Test input: University, Cat, Alex, Marble, Tampa

Expected output: Alex, Car, Marble, Tampa, University

Test input: Apple, 2017Mercedes, Car, New, Zebra

Expected output: An exception will be thrown with the message Word found which does not start with a letter.

Write a program in Java which accepts an input text file containing

4 Required Java code 1 public interface Sorter public void sortFileContent (String fileName); 1 public class StringSorter implements Sorter public void sortFileContent (String fileName) throws RuntimeException 4 // Implement this method // Do not forget to throw RuntimeException when // a word does not start with a letter 10 12 13 14 15 16 17 public static void main(String[] args) StringSorter fileSorter fileSorter.sortFileContent ("input.txt"); new StringSorterO

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!