Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

String Problem

For each numerical value 0, 1, 2, ...9 (0 <= NUMBER <= 9), embedded in a sentence, convert that value to its equivalent English text.

Print the converted sentence both to the screen and to an output file. Your input 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.

See the examples below.

Examples:

Input Record: 3 foxes were chasing 5 rabbits and 10 ducks.

Output Record: Three foxes were chasing five rabbits and 10 ducks.

Input Record: I used 3 eggs out of the 12 for the cake.

Output Record: I used three eggs out of the 12 for the cake.

Input Record: 1 picture is worth 1000 words.

Output Record: One picture is worth 1000 words.

Input Record: There are 260 students enrolled in Java.

Output Record: There are 260 students enrolled in Java.

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 firemen worked quickly.

Prompt the user for the name of the input file. Name your output file "outSentences.txt" . Save the output file in the same directory 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.

The constructor will call a method to convert the original sentence. You are to use only a select few methods of the StringBuilder class for the conversion.

These are the only methods of the String and StringBuilder class you are permitted to use:

StringBuilder: String: constructors constructors charAt( ) charAt( ) indexOf( ) length( ) length( ) replace( )

You are also permitted the use of the isDigit( ) method 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 call the get method( ) of the Converter class to get the converted string, and print this string both to the screen and to a file.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93124613

Have any Question?


Related Questions in Computer Engineering

Suppose you want to back up a huge file to a cd-r you can

Suppose you want to back up a huge file to a CD-R. You can do this by splitting the file into smaller pieces and backup up those pieces separately. Write a utility program named FileSplitter that splits a large file into ...

Uranium vi fluoride is crucial for the enrichment of

Uranium (VI) fluoride is crucial for the enrichment of weapons-grade uranium. If a 1.0 mol sample of helium effuses in 255 s, how many seconds will it take for the same amount of uranium (VI) fluoride to effuse under the ...

Suppose kelvin has seven controls listed as the top tier of

Suppose Kelvin has seven controls listed as the top tier of project initiatives. At his next meeting with Charlie, he provides a rank-ordered list of these controls with projected losses over the next 10 years for each i ...

Suppose you want to represent graphs where the number of

Suppose you want to represent graphs where the number of nodes is unknown in advance, and the nodes IDs are arbitrary (not contiguous). You want the following operations to be performed efficiently: Add a node. Remove a ...

Customers for a restaurant arrive at an average rate of 36

Customers for a restaurant arrive at an average rate of 36 customers per hour during lunchtime. a. Write the Poisson probability distribution function with the specific parameters for this problem. b. Rewrite the probabi ...

Consider the car-caravan analogy from section 4 in chapter

Consider the car-caravan analogy from Section 4 in Chapter 1.  In this problem, assume a propagation speed of 120 km/hr and that each toll booth takes 8 seconds to service a car. a) Suppose the caravan of 10 cars begins ...

Question sunshine health corporation is seeking to improve

Question : Sunshine Health Corporation is seeking to improve overall connectivity across their corporate campus near the Hawaii Kai Marina, Honolulu, Hawaii. The campus buildings have recently been updated, thus the LANs ...

Represent each of the following values in the ieee 754

Represent each of the following values in the IEEE 754 32-bit format, truncating inexact values. Indicate the percent error of the value stored compared to the exact value. This will require you to convert the 32 bit flo ...

A chemistry student needsnbsp600 mlnbspof carbon

A chemistry student needs 60.0 mL of carbon tetrachloride for an experiment. By consulting the  CRC Handbook of Chemistry and Physics , the student discovers that the density of carbon tetrachloride is 1.59 g.cm^-3. Calc ...

In a survey of 100 people 40 were casual drinkers event d

In a survey of 100 people, 40 were casual drinkers (event D), and 60 did not drink (event D). Of the ones who drank, 6 had minor headaches. Of the non-drinkers, 9 had minor headaches. Let D represent set of surveyed peop ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As