Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Coding Problem: C++ Modify existing code Add a menu to offer the user a choice of processing a telegram bill or translating a message into

Coding Problem: C++

Modify existing code

Add a menu to offer the user a choice of processing a telegram bill or translating a message into morse code. The menu should be the first thing displayed when your program begins executing.

Validate the users menu choice. If the user enters any number other than 1 or 2, a descriptive error message should display.

If the user chooses the translate to morse code option, your program (for now) should prompt the user for a single letter and then display the cooresponding morse code. If the users input can not be translated into morse code, then a descriptive error message should display.

Morse code:

, --..-- . .-.-.- ? ..--.. 0 ----- 1 .---- 2 ..--- 3 ...-- 4 ....- 5 ..... 6 -.... 7 --... 8 ---.. 9 ----. 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 --..

Sample output:

image text in transcribed

Existing Code:

#include #include

using namespace std;

int main() {

const double RATE_PER_FIVE = 1.50; const double RATE_PER_SINGLE = 0.50; string custName, street, city, state, zip; int words, blockFiveWords, remSingleWords, payment, change, dollars, quarters, dimes, nickels, pennies; double amountDue; cout > words; blockFiveWords = words / 5; remSingleWords = words % 5; amountDue = (blockFiveWords * RATE_PER_FIVE) + (remSingleWords * RATE_PER_SINGLE); cout > payment; 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); cout Welcome to Western Union Telegraph Company l Process Telegram Bill 2 Translate to Morse Code Enter your choice: 1 Enter the name of the customer: Larry Smith Enter street address: 122 Main Street Enter city: Charlotte Enter state: NC Enter zip code: 23499 Enter the number of words sent: 157 Larry Smith 122 Main Street Charlotte, NC 23499 Amount Owed: $47.50 Enter the amount received from customer: 5000 Denomination Number Dollars Quarters Dimes Nickels Pennies Welcome to Western Union Telegraph Company 1 Process Telegram Bill 2-Translate to Morse Code Enter your choice: 2 Enter a single letter: A The letter A translates to Welcome to Western Union Telegraph Company 1 Process Telegram Bill 2 -Translate to Morse Code Enter your choice: 2 Enter a single letter: h The letter h translates to Welcome to Western Union Telegraph Company l Process Telegram Bill 2 Translate to Morse Code Enter your choice: 8 8 is not a valid choice

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions

Question

Identify the cause of a performance problem. page 363

Answered: 1 week ago