Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete in C++ _______________________________________________________________________________________ 1. Write a function that takes a real number of ounces (representing the weight of a letter) and returns an

Please complete in C++ _______________________________________________________________________________________

1. Write a function that takes a real number of ounces (representing the weight of a letter) and returns an integer number of cents which represents the cost of mailing the letter. The rules for calculating the cost are as follows:

- If the weight is less than or equal to 1 ounce, the cost is 33 cents

- If the weight is greater than 1 ounce but less than or equal to 1.5 ounces, the cost is 40 cents

- If the weight is greater than 1.5 ounces but less than 2 ounces, the cost is 50 cents

- If the weight is greater than 2 ounces, the cost is 30 times the number of ounces

2. Write a function (call it getAns()) that prompts the user to enter a single letter from "a" to "d". It will return that letter to the calling function. It will not return anything but "a" through "d". If the user enters anything else, it will display an error message and ask the user to re-enter until they enter a value between "a" through "d".

3. Write a single statement that will both call getAns() and display the value returned.

4. Write a function called GetIntegerInRange() which takes 1 argument:

- an integer representing the largest acceptable value

The function prompts the user to enter a value between 0 and the passed in high value. It then accepts values from the user until a valid (i.e. between 0 and the high value) one is entered. If an invalid (i.e. smaller then 0 or greater then the high value) value is entered, display an error message and have the user try again.

Example: assuming the user passes in the value 120. The output should closely resemble:

Enter a number (0 to quit) between 0 and 120:

NOTE: You may assume that the passed in high value is greater than 0.

5. Write a COMPLETE program that uses GetIntegerInRange() to accept temperatures from the user in the range of 0 to 120. The value of 0 serves as an exit signal.

After all the temperatures have been entered, the program should display the following with brief labels:

- the average of the temperatures above 32

- the number of temperatures above 32

-the average of the temperatures below 32

-the number of temperatures below 32

You may assume that at least one temperature above 32 is entered and that one temperature below 32 is entered.

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_2

Step: 3

blur-text-image_3

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

Visualizing Health And Healthcare Data Creating Clear And Compelling Visualizations To See How Youre Doing

Authors: Katherine Rowell ,Lindsay Betzendahl ,Cambria Brown

1st Edition

1119680883, 978-1119680888

More Books

Students also viewed these Databases questions

Question

=+ 49-4 Explain how gender roles and gender identity differ.

Answered: 1 week ago