Question
Project Description For this part of the project, you will add the functionality to translate a complete message into morse code and the functionality to
Project Description | 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. C++ Programming Language Instructions: 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. 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. 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.
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. 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. |
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. |
****TelegramData.txt*****
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
*****Existing Code********
#include
#include
using namespace std;
int main()
{
string cName, stAddress, city, state; char letter;
int zip, NumberOfWords, received, change, choice;
double Amount;
int dol,qua,dim,nic,pen,rem;
//input cout << "Welcome to Western Union Telegraph Company" << endl;
cout << "1 - Process Telegram Bill" << endl << "2 - Translate to Morse Code";
cout << endl << endl;
cout << "Enter your choice: ";
cin >> choice;
cin.ignore();
switch (choice)
{
case 1:
cout << "Enter the name of the customer: ";
getline(cin,cName);
cout << "Enter street address: ";
getline(cin,stAddress);
cout << "Enter city: ";
getline(cin,city);
cout << "Enter state: ";
getline(cin,state);
cout << "Enter zip code: ";
cin >> zip;
cout << "Enter the number of words sent: ";
cin >> NumberOfWords;
Amount = (NumberOfWords/5)*1.5+(NumberOfWords%5)*0.5; //Computing amount Owed
cout <
cout << "Amount Owed: $"<< Amount << endl;
cout << "Entrer the amount received from customer: " ;
cin >> received;
cout << "Denomination\t Number ------------\t-------------" << endl;
rem = int(received-Amount*100);
dol = rem/100;
cout << "Dolars\t\t\t" << dol << endl;
rem = rem - dol*100;
qua = rem/25;
cout << "Quaters\t\t\t" << qua << endl;
rem = rem - qua*25;
dim = rem/10;
cout << "Dimes\t\t\t" << dim<< endl;
rem = rem - dim*10;
nic = rem/5;
cout << "Nickels\t\t\t" << nic << endl;
pen = rem - nic*5;
cout << "Pennies\t\t\t" << pen << endl;
return 0;
}
{
cout << endl << "Enter a single letter: ";
cin >> letter;
if (!(letter >= 'a' || letter <= 'z') || !(letter >= 'A' && letter <= 'Z'))
{
}
else if (letter == 'A' || letter == 'a')
{
cout << "The letter " << letter << " translates to .-" << endl << endl;
}
else if (letter == 'B' || letter == 'b')
{
cout << "The letter " << letter << " translates to -..." << endl << endl;
}
else if (letter == 'C' || letter == 'c')
{
cout << "The letter " << letter << " translates to -.-." << endl << endl;
}
else if (letter == 'D' || letter == 'd')
{
cout << "The letter " << letter << " translates to -.." << endl << endl;
}
else if (letter == 'E' || letter == 'e')
{
cout << "The letter " << letter << " translates to ." << endl << endl;
}
else if (letter == 'F' || letter == 'f')
{
cout << "The letter " << letter << " translates to ..-." << endl << endl;
}
else if (letter == 'G' || letter == 'g')
{
cout << "The letter " << letter << " translates to --." << endl << endl;
}
else if (letter == 'H' || letter == 'h')
{
cout << "The letter " << letter << " translates to ...." << endl << endl;
}
else if (letter == 'I' || letter == 'i')
{
cout << "The letter " << letter << " translates to .." << endl << endl;
}
else if (letter == 'J' || letter == 'j')
{
cout << "The letter " << letter << " translates to .---" << endl << endl;
}
else if (letter == 'K' || letter == 'k')
{
cout << "The letter " << letter << " translates to -.-" << endl << endl;
}
else if (letter == 'L' || letter == 'l')
{
cout << "The letter " << letter << " translates to .-.." << endl << endl;
}
else if (letter == 'M' || letter == 'm')
{
cout << "The letter " << letter << " translates to --" << endl << endl;
}
else if (letter == 'N' || letter == 'n')
{
cout << "The letter " << letter << " translates to -." << endl << endl;
}
else if (letter == 'O' || letter == 'o')
{
cout << "The letter " << letter << " translates to ---" << endl << endl;
}
else if (letter == 'P' || letter == 'p')
{
cout << "The letter " << letter << " translates to .--." << endl << endl;
}
else if (letter == 'Q' || letter == 'q')
{
cout << "The letter " << letter << " translates to " << endl << endl;
}
else if (letter == 'R' || letter == 'r')
{
cout << "The letter " << letter << " translates to .-." << endl << endl;
}
else if (letter == 'S' || letter == 's')
{
cout << "The letter " << letter << " translates to ..." << endl << endl;
}
else if (letter == 'T' || letter == 't')
{
cout << "The letter " << letter << " translates to -" << endl << endl;
}
else if (letter == 'U' || letter == 'u')
{
cout << "The letter " << letter << " translates to ..-" << endl << endl;
}
else if (letter == 'V' || letter == 'v')
{
cout << "The letter " << letter << " translates to " << endl << endl;
}
else if (letter == 'W' || letter == 'w')
{
cout << "The letter " << letter << " translates to .--" << endl << endl;
}
else if (letter == 'X' || letter == 'x')
{
cout << "The letter " << letter << " translates to -..-" << endl << endl;
}
else if (letter == 'Y' || letter == 'y')
{
cout << "The letter " << letter << " translates to -.--" << endl << endl;
}
else if (letter == 'Z' || letter == 'z')
{
cout << "The letter " << letter << " translates to --.." << endl << endl;
}
{
cout << "Sorry " << choice << " is not a valid choice." << endl;
}
}
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started