Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

prohibited Lab 3: Functions - Returns Copyright C2021 - Howard Community College All rights reserved. Unauthorized duplication prohibited. In this lab, you will be converting

prohibited Lab 3: Functions - Returns Copyright C2021 - Howard Community College All rights reserved. Unauthorized duplication prohibited. In this lab, you will be converting Lab 2: Decisions and Loops into a program that uses functions for several of the activities. With only one exception (noted below), the calculations and the output are EXACTLY the same as the calculations and output in Lab 2. The main purpose of this lab is to create and use functions and return values.

The program must create the following functions:

1. A void function that displays the title of the program, the copyright statement, and the welcome message with your name as the owner.

2. A function that returns an integer value that displays the main menu. The function should display the menu and return the entry no matter what value was entered. The switch statement in main() should be used for validation.

3. A function that returns an integer value that is used to determine exactly how many of the selected item is purchased. The function must have a string as a parameter. The code should send in the string to use in the prompt and the error message (for example pens). The function should perform the entry and do the validation. Once the value entered is valid, the function must return the value to main().

4. A function that returns an integer value that displays the menu to determine if the paper is purchased by the ream or the case. The function must perform the validation and then return the entered value once a valid entry is made.

5. A void function that is used to display the final output at checkout. The function must have four double parameters (one for each of the subtotals of the four items potentially purchased). The fifth parameter is an indicator of whether there is a ink discount for the price of the paper. This function must perform the paper discount calculation, the grand total calculation, the sales tax calculation, and the final total calculation. This function must also display the goodbye message.

6. A Boolean function that is used to determine if the user really wants to Coppheckout if they select option 5. This is the extra credit function from CE- Return and/or CE-Pass by Reference. It is required for this lab. The display of the final total only occurs if the user selects 'y' or 'Y', they really want to exit the program. If they select 'n' or 'N', the code must redisplay the main menu and allow the user to continue to purchase items. If the users enter anything other than 'y', 'Y', 'N' or 'n', they should get an error message an be required to retry. This is different from Lab 2!!

7. EXTRA CREDIT - An integer function that keeps track of the total number of pens purchased over the course of the customers shopping. This must be done using a static int variable in the function. The function returns the grand total number of pens purchased to main(). This grand total is used to calculate the subtotal for the pens.

NOTES:

1. All functions MUST be declared with prototypes.

2. All functions MUST use return values where indicated. Only two functions are void functions.

3. All functions MUST have a comment.

4. Almost all of the code can be used exactly as written in Lab 2 (once you fixed any defects that I identified to you when I graded the lab). This is primarily an exercise in cutting and pasting code functions. icatisko ere ibited. You have been hired by an office supply store served; main into the Follow the sample outpur unity C

Lab 2 instructions:

Your job is to create a program that allows customers to purchased one or more the items in the store inventory. Customers will have the option to buy Printer Ink, Printer Paper, Staplers and Pens from your store. You need to create a program to allow the customers to buy each of these items and then display the total due at the end (including the state sales tax).

creen shots to determine how your program must run and then display the data. The first two lines of output must be the title of the program and the copyright statement. Place your name as the owner of the store (CMSY-141 Office Supplies).

Using a menu, your program must ask the customer what item they want to purchase. If the customer indicates an item that your store does not sell, an error message must display telling the customer that you do not sell that item.

If the customer indicates a valid item, ask the customer how many of the item they want to buy. Make sure that the input is a positive number greater than zero before proceeding. If the value is not positive, display a specific error message and make sure the customer has the ability to reenter the value until they enter in a valid value. OP

Calculate and display the subtotal to the customer after each purchase that they make. The prices are as follows:

Printer Ink cartridges is $40.25 each. You can only buy a whole number of cartridges

Staplers are $8.00 each unless the customer enters the coupon code disc stap". If the customer enters the correct code, the stapler is $5.75. The only valid entries for the coupon code are "disc stap" or "NONE". Any other entry must be flagged as invalid, and the customer must be allowed to reenter the coupon code immediately. The code must display the appropriate error message when this occurs.

Printer Paper can be purchased by the ream or the case. The program must ask the customer which unit they wish to purchase. The printer paper is $6.00 per ream and $34.50 per case. However, if the customer buys at least four printer ink cartridges in total any time during the sales transaction, they get printer paper for half price. This printer paper discount is only applied at the very end when calculating the final total. The program must indicate the amount of the printer paper discount only if there is a discount code must not display a discount amount of $0.00 The process of allowing ty College Alles

Pens: 1-5 pens: $1.99 each

6-10 pens: S1.69

each 11 or more: $1.29

the customer to select an item and your program displaying the subtotal must continue until the customer selects to checkout when prompted for the item they want to purchase. Your program must then display the total amount due and the total amount of the discount (if there is any). The code must calculate the state sales tax (the tax rate is 6%). The code must display the total tax. Finally, the code must display the grand total due.

Submit your.cpp code file and screenshots via Canvas.

EXTRA CREDIT:

Keep track of the number of pens purchased. Calculate the total cost of the pens based on the total number of pens purchased accumulated over time. For example:

If the customer buys 5 pens, the cost is (5 * $1.99) = $9.95

The customer then goes in and buys another 5 pens. In the base program, the ited subtotal cost of the pens would be (5 * $1.99) +(5 * $1.99) = $19.90. In the extra credit version of the program, the subtotal cost of the pens should now be (10 * $1.69) = $16.90. This is worth 5 extra points. Copyright 2021 - Howard Community College All rights reserved; Unauthorized duplicember

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

10' Aluminum Steel C -10'- -10- A B 1000 lb

Answered: 1 week ago

Question

Given find the value of k. es 1 e kx dx = 1 4'

Answered: 1 week ago