Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Write a language translation program that permits the entry of a word in English and prints the corresponding word in another language. The

In C++ Write a language translation program that permits the entry of a word in English and prints the corresponding word in another language. The input file dictionary.txt contains up to 128 lines. On each line there is word in English followed by its translation in Hawaiian. You may assume that each line contains exactly two words and that the English words in the file are in alphabetical order, as shown below:

above luna

below lalo

bird manu

branch lala

canoe wa'a

Create the input file using data on the next page. Read data from the input file into two parallel arrays. Use arrays of maximum size 128. In case the input file contains data for more than 128 names, print an error message such as The file contains more than 128 lines! and terminate the program. Change the Binary Search function to search the parallel arrays, then test it in a loop as it is shown in Program 8-3. Prompt the user to enter a word in English, such as bird then call the Binary Search function to search for bird. If found, display the Hawaiian word for bird: manu, otherwise display an error message. Keep track of the number of successful searches for each student in another array. When done searching, write the arrays to an output file named results.txt, as shown below.

5 below lalo 11 bird manu 1 canoe wa'a

The first number on the first line, 5, shows that there were 5 searches for below, the first number on the second line, 11, shows that there were 11 searches for bird, and so on. Notice that the words that were not searched for, such as branch are not saved to the output file.

Create the input file dictionary.txt using the following data:

above luna below lalo bird manu branch lala canoe wa'a club hui coconut niu compose haku day la easy ma'alahi father makuakane float lana forest ulula'au garden mala garland lei gift makana hello aloha huge nunui kitchen lumikule large nui listen ho'olohe market makeke moon mahina mother makuahine name inoa parent makua pay uku porch lanai practice ho'oma'ama'a rice laiki room lumi sand one seaweed manauea shark mano sky lani star hoku student haumana thanks mahalo they lakou think mana'o tired maluhiluhi triggerfish humuhumunukunukuapua'a turtle honu twenty iwakalua watch uaki wave nanea wind makani work hana year makahik

*****************

Sample Output: Welina! Welcome! This program translates English words to Hawaiian. What is the input files name? disctionary.txt Please enter a word in English: triggerfish triggerfish in Hawaiian is humuhumunukunukuapua'a Do you want to search again? (y/n): y Please enter a word in English: computer Sorry, we do not have computer in our dictionary. Do you want to search again? (y/n): y Please enter a word in English: bird bird in Hawaiian is manu Do you want to search again? (y/n): y Please enter a word in English: triggerfish triggerfish in Hawaiian is humuhumunukunukuapua'a Do you want to search again? (y/n): y Please enter a word in English: triggerfish triggerfish in Hawaiian is humuhumunukunukuapua'a Do you want to search again? (y/n): n Your search history has been saved into an output file named results.txt.

********************

Sample Output File: 1 bird manu 3 triggerfish humuhumunukunukuapua'a

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe the essentials of Lewins field theory?

Answered: 1 week ago

Question

Decision Making in Groups Leadership in Meetings

Answered: 1 week ago