Write a program that starts by requesting the number of trees purchased (int), their height (double), and extra services bought (int).C++ Programming

Consider a company that sells trees that are priced by height. Customers have the choice of purchasing a tree on a “cash and carry” basis, of purchasing a tree and have it delivered (delivery service), or of purchasing a tree and having it both delivered and planted (planting service). Of course, the delivery and planting services have an extra cost (and customers do not have to buy them).

We summarize below the pricing information for trees.

  • Trees whose height is below one meter cost 50.

    • Trees whose height is three meters or more cost 299.50.

    • Trees whose height is one meter or more but less than two meters cost 109.

    • Trees whose height is two meters or more but less than three meters cost 199.

Pricing information for extra services is given below.

  • Delivery service costs 120 per tree.

    • The delivery service has a maximum cost of 600 per order. In other words, if a customer buys more than five trees than she only pays for five trees (5 × 120 = 600).

    • Planting services (which also include delivery) cost 50% of the trees’ cost.

Write a program that starts by requesting the number of trees purchased (int), their height (double), and extra services bought (int) and then displays an invoice as shown in the examples below. Assume that all trees purchased in one order have the same height.

Note that when the user is requested for information about the purchase of extra services,

  • “0” should be entered to indicate that no extra service was purchased;

    • “1” should be entered to indicate that delivery service was purchased;

    • “2” should be entered to indicate that planting service was purchased.

Your program should validate the purchase information given by the user (for instance, number of trees should not be negative and trees’ height should be a positive number). If the user input is not valid then an error message should be displayed and the program should request the purchase information, again.

Assume that the user always enters numbers as input for the program. Note that the invoice created by your program should contain the same information as in the given examples. All costs in the invoice should be displayed with two digits after the decimal point. Perfect alignment of the different items in the displayed invoice is not a requirement.

Attachments:

Instructions Files

C++ Programming Experts

expert
Dinh Hong P.
C++ Programming

20 Answers

expert
Eric Bell
C++ Programming

88 Answers

View More Experts
Disclaimer

The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.

Get Free Quote!

267 Experts Online