Question: For each numerical value, 1,2,...9, (0

For each numerical value, 1,2,...9, (0 <= Number <= 9), embedded in a sentence, covert that value to its equivalent English text. Print the coverted sentence both to the screen and to an output file. Your output file consists of a variable number of records. Each record is a sentence of length <= 80 characters. More than one numerical value in the given range may appear in a sentence. You must deal with upper and lower case issues. If a line begins with a single digit, write that digit as a word starting with an uppercase letter.

Example:

Input record:

3 foxes were chasing 5 rabbits and 10 ducks.

Output record:

Three foxes were cahsing five rabits and 10 ducks.

--------------

Create the following as an input file for testing:

The 8 eggs were separated into 3 groups.

5 boys and 7 girls were present.

He was 1 hour and 5 minutes late.

She ate 3 dozen doughnuts!

4 dogs were chasing 3 cats.

The captain said, "This is the 0 hour".

I tried to call you 9 times today; Ann tried 6 times!!

The 12 foreman worked quickly.

Promput the user for the name of the input file. Name your output file "outSetence.txt". Save the output file in the same directionry as your code to make grading on different systems easier. More details:

Create two class files. One class is the Converter. It has a StringBuilder field for the original sentence and a String field for the converted sentence.

You are to use only the methods of the StringBuiler class for thre conversion. These are the only methods of the String and StringBuilder class you are permited to use:

StringBuilders:

constructors, charAt(), indexOf(), length(), replace()

String:

constructors, charAt(), length()

You will also have to use methods from the Character class.

The second class is the driver class. The driver will contain the main() method. The main() method will open a file for input. Read the file line by line and send each line to the Converter class. The main() method will class the get method() of the converter class to get the converted string, and print this string both to the screen and to the file.

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!