Question: PLEASE HELP WITH THIS C++ PROGRAMMING PROJECT! For this part of the project, you will add the functionality to translate a complete message into morse

PLEASE HELP WITH THIS C++ PROGRAMMING PROJECT!

For this part of the project, you will add the functionality to translate a complete message into morse code and the functionality to process a data file containing multiple records. You will also modify your input validation code to give the user an unlimited number of chances to enter valid responses. Your program should continue to run until the user chooses a quit option from your menu.

Instructions:

1.Add an option to the menu to offer the user a choice of processing a data file. Add another option to quit the program. The menu should be the first thing displayed when your program begins executing. The menu format should match the one in the Sample Output on page 3.

2. Allow the user to continue making menu choices until they choose the option to quit. Always display the menu before prompting the user for a menu option. Properly handle an invalid menu choice. The user should have an unlimited number of chances to enter a valid menu choice.

3.Modify the code you wrote in Project 2 to validate the users input for payment amount to allow user an unlimited number of chances to enter a valid payment amount

4.Modify the code you wrote in Project 2 to translate a single letter into a morse code. Your code should now be able to efficiently translate a complete message into morse code. (no code duplication). All white spaces in message should be translated into 3 corresponding white spaces in morse code.

HINT: Use the string class member functions at() and length(). See code example on Moodle.

If any part of the message cannot be translated into morse code, instead of displaying an error message like you did in Project 2, your code should display the untranslated character.

5. Add functionality to create and display telegram bills by reading input from the TelegramData.txt text file. When the user selects the option to process a data file, telegram bills should be created and displayed for every record in the file without the user needing to do anything else. The TelegramData .txt file contains 5 records, but your program must be able to process an identically formatted file with any number of records without counting the records. You do not need to process payment information if this option is chosen by the user.

****** LINK FOR TelephoneData.txt***** https://moodle.cpcc.edu/pluginfile.php/1098482/mod_assign/intro/TelephoneData.txt

*** Data that is in Link above:

Leslie Knope 1456 Plymouth Street Pawnee IN 47408 117 Tom Haveford 689 Lil Sebastian Avenue Eagleton IN 47320 34 April Ludgate 1123 9th Avenue Wamapoke IN 48034 60 Jery Gergich 3124 Woodbridge Road Pawnee IN 47407 378 Donna Meagle 1200 Elysian Fields Blvd Eagleton IN 47322 245 

****

SAMPLE OUTPUT:

Welcome to Western Union Telegraph Company

1 Process Telegram Bill

2 Translate to Morse Code

3 Process a Data File

4 - Quit

Enter your choice: 2

Enter a message: Thats it!

Translation: - . . . . . - - . . . . . - !

1 Process Telegram Bill

2 Translate to Morse Code

3 Process a Data File

4 - Quit

Enter your choice: 3

Leslie Knope

1456 Plymouth Street

Pawnee, IN 47408 Amount Owed: $35.50

Tom Haveford

689 Lil Sebastian Avenue

Pawnee, IN 47408 Amount Owed: $11.00

April Ludgate

1123 9th Avenue

Wamapoke, IN 48034 Amount Owed: $18.00

Jery Gergich 3124 Woodbridge Road

Eagleton, IN 47322 Amount Owed: $114.00

Donna Meagle

1200 Elysian Fields Blvd

Eagleton, IN 47322 Amount Owed: $73.50

1 Process Telegram Bill

2 Translate to Morse Code

3 Process a Data File

4 - Quit

Enter your choice: 44

44 is not a valid choice

1 Process Telegram Bill

2 Translate to Morse Code

3 Process a Data File

4 - Quit

Enter your choice: 4

Thank you. Closing program.

********** EXISTING CODE**********

#include // needed for cin/cout class

#include // needed for string class

#include // needed for output formatting

using namespace std;

int main()

{

//declear

const double Per_Five = 1.50;

const double Per_Single = 0.50;

//declear

string CustName, street, city, state, zip;

int words, BlockFiveWords, remSingleWords, payment, change, dollars, quarters, dimes, nickels, pennies, choice;

double amountDue;

char letter;

cout<< "Welcome to Western Union Telegraph Company "

<< "1 - Process Telegram Bill "

<< "2 - Translate to Morse Code"<

cout<<"Enter your choice:" << endl;

cin>>choice;

cin.ignore();

switch (choice)

{

case 1:

//prompts for input

cout<< "Enter the name of the customer: ";

getline(cin, CustName);

cout << "Enter street address: ";

getline(cin,street);

cout<<"Enter the city:";

getline(cin,city);

cout<<"Enter State: ";

getline(cin,state);

cout<<"Enter zip:";

getline(cin,zip);

cout<<"Enter the number of words to be sent: ";

cin>>words;

// find the number of 5 blocks of words and the remainder

BlockFiveWords = words /5;

remSingleWords = words % 5;

//calculate total amount due

amountDue = (BlockFiveWords * Per_Five) + (remSingleWords * Per_Single);

//display input

cout<< endl << CustName << endl;

cout<< street << endl;

cout<< city << "," << state << " " << zip << endl;

//display amount owned,fixed decimal at 2 places

cout<< setprecision(2)<< fixed;

cout << "Amount Owned: " << amountDue << endl;

// enter amount in pennies

cout<< endl<< "Enter the amount recieved from customer: ";

cin>>payment;

if (payment>=amountDue)

{

//calculat the amount of each denomination

change = payment - (amountDue * 100);

dollars = change / 100;

quarters = (change % 100 ) / 25;

dimes = ((change % 100 )- (quarters*25)) / 10;

nickels+(change - (dollars*100)-(quarters*25)-(dimes*10))/5;

pennies = change - (dollars*100)-(quarters*25)-(dimes*10)-(nickels*5);

//Display change due in appropriate denominations

cout <<\

endl << left <

cout << left << setw(15) << "-----------" << right << setw(15)<< "----------" << endl;

cout << "Dollars " << right << setw(15) <

cout << "Quarters" << right << setw(15) << quarters << endl;

cout << "Dimes" << right << setw(18) << dimes << endl;

cout << "Nickles" << right << setw(16) << nickels << endl;

cout << "Pennies" << right << setw(16) << pennies << endl; }

else { cout<<"Erorr! The customer has not paid enough." << endl; }

break;

case 2:

cout<< endl << "Enter a single letter: " << endl;

cin>>letter;

if (letter =='A'|| letter =='a')

{cout<< "The letter" << " " << letter << " " << "translates to .-" << endl;

}

else if (letter == 'B'|| letter =='b')

{

cout<< "The letter" << " "<< letter << " " << "translates to -..." << endl;

}

else if (letter =='C'||letter == 'c')

{

cout<< "The letter" << " "<< letter << "translates to -.-." << " " << endl;

}

else if (letter =='D'|| letter =='d')

{ cout<< "The letter" << " "<< letter << " " << "translates to -.." <

else if (letter=='E'|| letter=='e')

{

cout<< "The letter" << " "<< letter << " " << "translates to ." << endl;

}

else if (letter=='F'||letter=='f'){

cout<< "The letter" << " " << letter << " " << "translate to ..-." << endl; }

else if ( letter=='G'||letter=='g')

{cout<<"The letter" << " "<< letter << " " << "translates to --." << endl; }

else if (letter == 'H'|| letter =='h')

{cout<< "The letter" << " "<< letter << " " << "translates to ...." << endl; }

else if (letter=='I'|| letter=='i')

{ cout<< "the letter" << " "<< letter << " " << "translates to .." << endl;}

else if (letter=='J'||letter=='j'){

cout<< "The letter" << " "<< letter << " " << "translates to .---" << endl;

}

else if (letter=='K'||letter=='k'){

cout<< "The letter" << " "<< letter << " " << "translates to -.-" << endl;

}

else if (letter=='L'||letter=='l'){

cout<< "The letter" << " "<< letter << " " << "translates to .-.." << endl;

}

else if (letter=='M'||letter=='m')

{ cout<< "The letter" << " "<< letter << " " << "translates to --" << endl;

}

else if (letter=='N'||letter=='n') {

cout<< "The letter" << " "<< letter << " " << "translates to -." << endl;

}

else if (letter=='O'||letter=='o')

{

cout<< "The letter" <<" "<< letter << " " << "translates to ---" << endl;

}

else if (letter=='P'||letter=='p')

{ cout<< "The letter" << " "<< letter << " " << "translates to .--." << endl;

}

else if (letter=='Q'||letter=='q') {

cout<< "The letter" << " "<< letter << " " << "translates to --.-" << endl;

}

else if (letter=='R'||letter=='r') {

cout<< "The letter" << " "<< letter << " " << "translates to .-." << endl;

}

else if (letter=='S'||letter=='s'){

cout<< "The letter" << " "<< letter << " " << "translates to ..." << endl;

}

else if (letter=='T'||letter=='t'){

cout<<"The letter" << " "<< letter << " " << "translates to -"<< endl;

}

else if (letter=='U'||letter=='u'){

cout<<"The letter" << " " << letter << " " << "translates to ..-" << endl;

}

else if (letter=='V'||letter=='v'){

cout<< "The letter" << " "<< letter << " " << "translates to ...-" << endl;

}

else if (letter=='W'||letter=='w')

{

cout<<"The letter" << " "<< letter << " " << "translates to .--" << endl;

}

else if (letter=='X'||letter=='x') {

cout<<"The letter" << " "<< letter << " " << "translates to -..-" << endl;

}

else if (letter=='Y'||letter=='y') {

cout<< "The letter" << " "<< letter << " " << "translates to -.--" << endl;

}

else if (letter=='Z'||letter=='z')

{

cout<< "The letter" << " "<< letter << " " << "translates to --.."<

}

break;

default:

cout<<"Error!" << " " << choice << " " << "is not a valid choice." << endl;

break;

}

return 0;

}

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!