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

C Program for E-commerce Checkout System

The assignment requires students to design a simple e-commerce checkout system in C that calculates the final cost of a product, applying a tiered discount and regional tax. Key components include user input validation, discount calculation based on price tiers, and formatted output display. Submissions must include a flowchart and a runnable C program file, with a total of 20 marks awarded based on problem-solving, code implementation, and output formatting.

Uploaded by

isaacmuwonge201
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)
6 views4 pages

C Program for E-commerce Checkout System

The assignment requires students to design a simple e-commerce checkout system in C that calculates the final cost of a product, applying a tiered discount and regional tax. Key components include user input validation, discount calculation based on price tiers, and formatted output display. Submissions must include a flowchart and a runnable C program file, with a total of 20 marks awarded based on problem-solving, code implementation, and output formatting.

Uploaded by

isaacmuwonge201
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

Principles of Programming with C Year I, Semester I

ASSIGNMENT: Simple E-commerce Checkout System


(C Programming)

Course: Principles of Programming with C


Due Date: 22nd October 2025
Total Marks: 20 Marks

1. Overview and Learning Objectives


This assignment requires you to design and implement a simple C program that calculates the
final cost of a single product purchased from an online store. The program will simulate key
business logic by applying a tiered discount based on the item’s price and then adding a
regional tax.
This exercise directly assesses your mastery of:

1. Problem-Solving: Translating a requirement into a clear Flowchart or Pseudocode


that handles multiple decision paths.

2. Variables & Constants: Using appropriate C data types (float or double) for currency
and defining constants.

3. Input/Output: Using printf() and scanf() to interact with the user.

4. Operators: Performing arithmetic calculations (multiplication, division, addition, sub-


traction).

5. Conditional Control Flow: Using the if-else if-else structure to implement mu-
tually exclusive, tiered business logic.

2. Program Requirements
Your C program must perform the following steps sequentially:

A. Initialization
• Define a constant for the Tax Rate set at 18% (0.18).

B. User Input
• Prompt the user to enter the base price of a single item in Uganda Shillings (UGX).

1
Principles of Programming with C Year I, Semester I

C. Input Validation (Must use an if statement)


• You must check if the entered base price is a positive value (greater than zero).

• If the price is not positive (0 or a negative number), the program must display an “Error:
The item price must be greater than zero.” message and exit gracefully.

D. Discount Calculation (Must use the if-else if-else structure)

The program must check the base price and apply one and only one discount according to
the following tiered structure:

1. Premium Discount: Apply a 15% discount if the base price is greater than 150,000
UGX.

2. Standard Discount: Apply a 10% discount if the base price is greater than 50,000
UGX AND less than or equal to 150,000 UGX.

3. No Discount: Apply a 0% discount if the base price is less than or equal to 50,000
UGX.

E. Final Cost Calculation

After determining the discount, the program must calculate:

1. Discount Amount: The monetary value of the applied percentage discount.

2. Price After Discount: Base Price – Discount Amount.

3. Tax Amount: 18% of the Price After Discount.

4. Final Total Cost: Price After Discount + Tax Amount.

F. Output Display

The program must display a clear, formatted receipt showing all the financial components,
rounded to two decimal places, before exiting. You must clearly state the percentage discount
applied.
Example Output (Illustrative for a 15% discount)

E-COMMERCE RECEIPT
============================================
Base Price: 200000.00 UGX
Discount Applied (15%): -30000.00 UGX
Price After Discount: 170000.00 UGX
Tax (18%): +30600.00 UGX
============================================
FINAL TOTAL COST: 200600.00 UGX

2
Principles of Programming with C Year I, Semester I

3. Submission Requirements
You must submit two files:

1. Problem-Solving Plan: A single document containing the Flowchart (hand-drawn


and scanned/photographed clearly, or digitally drawn) that illustrates the program’s logic.

2. C Program File: A single .c file named checkout system.c containing your complete,
compiled, and runnable program.

4. Sample Test Cases


Test your program with the following inputs and verify that your output matches the expected
results:
Test Case Base Price Expected Expected Price Expected
(UGX) Discount (%) After Discount Final Total
(UGX) Cost (UGX)
Case 1 200,000.00 15% 170,000.00 170,000 × 1.18 =
(Premium) 200,600.00
Case 2 100,000.00 10% 90,000.00 90,000 × 1.18 =
(Standard) 106,200.00
Case 3 150,000.00 10% 135,000.00 135,000 × 1.18 =
(Boundary 1) 159,300.00
Case 4 50,000.00 0% 50,000.00 50,000 × 1.18 =
(Boundary 2) 59,000.00
Case 5 −10.00 N/A N/A Error
(Error) Message Only

3
Principles of Programming with C Year I, Semester I

5. Grading Rubric (Total: 20 Marks)

Criteria Marks Description of Achievement


A. Problem-Solving Plan (5 Marks)
Flowchart/Pseudocode 5 Plan is logically sound, correctly shows in-
Logic put/validation, and clearly maps all three tiered
discount paths using decision symbols.
3 Plan is mostly correct but lacks clarity in one area (e.g.,
incomplete validation logic or incorrect symbol usage).
1 Plan is confusing, incomplete, or does not address the
tiered discount requirement.
B. Code Implementation: Core Requirements (11 Marks)
Initialization & 2 Correct use of #define/const for Tax Rate and appro-
I/O priate use of float/double data types and scanf().
Input Validation 3 Correctly uses a single if statement to check price > 0
(C) and handles the error case with a clean exit.
Tiered Discount 6 Correct implementation of a mutually exclusive
Logic (D) if-else if-else structure that applies the correct dis-
count for all three tiers.
C. Code Implementation: Calculations & Output (4 Marks)
Calculations (E) 2 All four required calculations (Discount Amount, Price
After Discount, Tax Amount, Final Total Cost) are
arithmetically correct.
Output Formatting 2 Output is clear, professionally formatted as a receipt,
(F) and all calculated values are displayed rounded to two
decimal places.
TOTAL 20 Marks

You might also like