Question
A file named customers.txt contains the names of customers for a local hairdressing salon. Unfortunately, the data in the file is in no particular order
A file named customers.txt contains the names of customers for a local hairdressing salon. Unfortunately, the data in the file is in no particular order yet the owner of the salon would like the data in alphabetical order.
Code a Java program that reads the contents of the file into an array of Strings, sorts the array of Strings into alp habetical order, and then writes the content of the array to a file named sortedCustomers.txt. customers.txt contains one name per line and may contain data similar to:
Smith, Alexandra
Downes, Trish
Akbal, Maria
Note the following:
You cannot assume how many lines of text are in the file.
You cannot assume that the file exists.
When storing the names in the array you may assume an array size of 500 elements.
When coding the names to the sortedCustomer.txt file there should be one name per line. For example: Akbal, Maria Downes, Trish Smith, Alexandra
Your code must use appropriate methods with parameter passing to solve the question.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started