logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

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

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

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 checkout 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 of the 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 from main into the functions.

 

 

Lab 2 instructions:

You have been hired by an office supply store. 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).

 

Follow the sample output screen 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.

 

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. The code must not display a discount amount of $0.00.

 

Pens: 1-5 pens: $1.99 each 6-10 pens: $1.69 each

11 or more: $1.29 each

 

The process of allowing 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.

 

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

672 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

622 Answers

Hire Me
expert
Husnain SaeedComputer science

783 Answers

Hire Me
expert
Atharva PatilComputer science

862 Answers

Hire Me

Get Free Quote!

359 Experts Online