Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ You will add functionality to calculate the total cost of all telegram bills in the data file and you will break up your program

C++

You will add functionality to calculate the total cost of all telegram bills in the data file and you will break up your program into manageable pieces. Instead of having one long main function that contains all the statements necessary to solve the problem given in previous projects, you must write several small functions that each solve a specific part of the problem. These small functions should then be executed in the correct order to implement a complete solution. The named constants you used for the amount owed calculation should now be made global so you won't have to pass those values to any function.

Write a function that only accepts the number of words sent and returns the amount owed.

In the 1850's, the hottest new technology was the telegraph. Messages or telegrams could be sent via electrical forces traveling through a wire. Write a program that will generate a bill for sending a telegram, accept payment and instruct cashier how to give change. The amount owed is based on the number of words sent. Customers are charged at a rate of $1.50 for blocks of 5 words and $0.50 for single words.

Prompt user for the customers name, street address, city, state, zip code and number of words sent.

Calculate and display a telegram bill with all information specified in the Sample Output

After displaying the telegram bill, prompt user for the amount of money received from the customer. The user should supply the amount given in pennies, for example 275 instead of 2.75.

Calculate the amount of change owed and display the number of dollars, quarters, dimes, nickels, and pennies that the customer should receive.

add code to randomly generate the customers payment. That number should be an integer. Use the number for the payment rather than the one received from the user (overwrite the value stored in your payment variable with the random number). Each time the program is run, a different random number should be generated for the payment.

validate the users input for payment amount to allow user an unlimited number of chances to enter a valid payment amount

display the number of dollars, quarters, dimes, nickels, and pennies that the customer should receive as change only if the payment amount is greater than the amount owed. Otherwise, display a descriptive error message.

Your program's output should be formatted in the same manner as the Sample Output

Use the Divide and Conquer approach to modularize your program.

Write a function that displays the menu.

Add a menu to offer the user a choice of processing a telegram bill or translating a message into morse code. 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.

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.

Write a function that accepts a message and returns the cooresponding morse code. The main function, not this function, should display the morse code.

If the user chooses the translate to morse code option, your program 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.

Add functionality to verify that the message entered by the user only contains valid letters. If it doesn't, then a descriptive error message should display and the user should be given an unlimited number of chances to enter a message that only contains valid letters.

HINT: Use the string class member functions at() and length().

If any part of the message cannot be translated into morse code, instead of displaying an error message. your code should display the untranslated character.

Write a function that reads the specified text file and creates and displays telegram bills for each record in the file.

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.

Make the local named constants

Add functionality to find and display the cost of the largest telegram bill in the text file. Your code MUST be efficient and work no matter how many records are in the text file.

Add functionality to calculate the total cost of all the telegram bills in the text file. Display the total cost after displaying the individual telegram bills. Make sure your program will correctly calculate the total cost no matter how many records are in the text file. The format should match the one in the Sample Output

FINAL SAMPLE OUT PUT

MOEAW CODE

TEXT FILE

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions