0% found this document useful (0 votes)
8 views4 pages

Lab Function Question

The document outlines a C++ programming task involving an online souvenir shop and a digital marketing service provider. It requires the creation of functions to handle user input for product purchases, calculate total amounts, and generate receipts, as well as a program to compute payments for customers of digital marketing services with discounts for long-term clients. Additionally, it specifies the structure of the input and output for the program, including examples of how the data should be processed and displayed.

Uploaded by

2023828024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Lab Function Question

The document outlines a C++ programming task involving an online souvenir shop and a digital marketing service provider. It requires the creation of functions to handle user input for product purchases, calculate total amounts, and generate receipts, as well as a program to compute payments for customers of digital marketing services with discounts for long-term clients. Additionally, it specifies the structure of the input and output for the program, including examples of how the data should be processed and displayed.

Uploaded by

2023828024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

QUESTION 1

The online souvenir shop offers the variety of souvenir such as postcards, key
chains, refrigerator magnets, stickers, mugs, plates and etc. The following table depicts the
hot selling products for this online shop:

Category Category Product Product Price per item


Code Description Code Description (RM)
11-002 Sport medal 4.50
A Metal Craft
11-076 Keychain 3.00
12-111 Coin plate 2.50
08-388 Sticker 1.50
B Gift and Craft
08-368 Mug 5.00
06-121 Postcard 1.00

a. Write a complete C++ function that can perform the following problems:

i.Function getInput(...) that ask the user to


• input the category code.
• input the product code together with the quantity the customer would like to
purchase.

This function received the addresses of the category code, product code and quantity
from the function call.

Function calcTotalAmount(...) to calculate the total amount of the product. This


function received reference parameter which are total amount, category description
and product description. This function also recieved category code, product code and
quantity as input parameters. The total amount will be accumulated because the
customer can buy the same or different category more than one. The number of
category will be inserted by the user.

Both functions above will be called repeatedly until the loop reach the number of
category.

b. Write a main program :

i.Declare variable numCategory, categoryCode, productCode, description, prodDescription,


quantity, totalAmount and totalAll.
ii.Insert the number of category to buy
iii.Call the function getInput(...)
iv.Call the function calcTotalAmount(...) to calculate the total amount and accumulated
it to get the total for all category.
v.Generate a receipt for each customer using the following format:
How many category to buy ? : 2

Enter Category : A
Enter Product Code : 11-076
Enter Quantity : 3
Amount : RM 9.00

Enter Category : A
Enter Product Code : 12-111
Enter Quantity : 4
Total Amount : RM 10.00

Total ALL : RM 19.00

QUESTION 2
WebUiTM offers 3 comprehensive cost of digital marketing services. Currently, WebUiTM
has 5 customers. 10% off the total payment is given to a customer who purchased a
service for more than one year. The following table shows the type, code and price for
each service.

Write a complete C++ program to calculate the payment of each customer, the total
payment for each type of service (before discount), the service with the highest total
payment (before discount) and the total payment for all 5 customers.
The following functions must be used in your solutions.

The sample of input and output for the program is based on the following figure.

You might also like