Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming - MorseConvert that converts a Text string into Morse CodeLinks to an external site. (kind of). The program will not convert

C++ Programming -

"MorseConvert" that converts a Text string into Morse CodeLinks to an external site. (kind of). The program will not convert the text to dashes and dots but to the words "dash" and "dot".

Define a structure that embodies the data in one line in the file codes.datimage text in transcribed.

Also:

It can be assumed that the codes will not change therefore you should define a constant equal to the size 36 (the number of codes in the codes.datimage text in transcribed file).

Define 2 other constants that will be used in place of the strings "dot" and "dash".

The MorseConvert program will need to load the file "codes.dat" with the mappings of the letters and numbers to the Morse Code.

Develop a function that has the following signature:

bool LoadMorseCodes(Code arrCodes[], const int iTotalCount)

The function will open the file codes.datimage text in transcribed, reads its contents and store the data in the array of "Code" structures passed to it. Finally the function should close the file before it exits.

Note: Even though there are exactly 36 codes, develop the function so that it "loops"

const int iTotalCount 

times and not a hard-coded 36.

Your function must use std::string functions to parse the data. I recommend functions like find() and substr().

Develop a function that has the following signature:

string GetCode(char c, Code arrCodes[], const int iTotalCount) 

The job of this function is to search through the array of Codes and locate the Morse Code that corresponds to the character

char c 

that is passed in as a parameter. Once the character is located the function should return a string containing the Morse code.

Develop a function that has the following signature:

string ConvertCodeToDotDash(string sMorseCode) 

The job of this function is to convert the Morse Code contained in

string sMorseCode 

to an equivalent string containing "dots" and "dashes".

Note: that the returned string will contain the actual words "dot" and "dash" and not some other kind of codes.

Develop a function that has the following signature:

void PlayMorseCode(string sDotDashCode) 

The job of this function is to play an audio tone (beep) that corresponds to the "dot"s and "dash"es in the string "sDotDashCode" which contain "dot"s and "dash"es and not "-" or ".".

Your function must use std::string functions to parse the "sDotDashCode" string. I recommend functions like find(), length(), substr(), and erase().

To play a "beep (Links to an external site.)Links to an external site." on the Windows computer, use the function "

Beep(1750, 500); 

To play "dot" and

Beep(750, 1000); 

To play "dash".

Your program should include "Windows.h"

Develop a function that has the following signature:

int main()

The job of this function is to declare an array of "Codes" as defined in the first function.

Next the function should load the codes into the array of "Codes" using the function

LoadMorsearrCodes(...) 

Next prompt the user for the string to convert. Iterate over the characters in the string, converting each one to the equivalent "dot" and "dash" using the functions

GetCode(...) and ConvertCodeToDotDash(...) 

to an equivalent string containing "dot"s and "dash"es.

Display the converted user input string as the dotted and dashed code.

Finally used the function

GetCode(...) and ConvertCodeToDotDash(...) 

to play out the dotted and dashed code using the function

PlayMorseCode(...) 

Codes.dat file contents:

A,.-

B,-...

C,-.-.

D,-..

E,.

F,..-.

G,--.

H,....

I,..

J,.---

K,-.-

L,._..

M,--

N,-.

O,---

P,.--.

Q,--.-

R,.-.

S,...

T,-

U,..-

V,...-

W,.--

X,-..-

Y,-.--

Z,--..

1,.----

2,..---

3,...--

4,....-

5,.....

6,-....

7,--...

8,---..

9,----.

0,-----

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

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

EXPLAIN the six steps in the termination interview.

Answered: 1 week ago

Question

What tools might be helpful?

Answered: 1 week ago