0% found this document useful (0 votes)
74 views

Lab 5

The document describes 3 programming exercises. The first asks to create a program that calculates sales commission for salespeople by taking gross sales as input and outputting earnings using a function. The second asks to write a function that checks if a number is prime and prints the result. The third asks to create a program that determines if a customer has exceeded their credit limit by taking account details as input and calling a function to calculate the new balance and check against the limit.

Uploaded by

cleophacerevival
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

Lab 5

The document describes 3 programming exercises. The first asks to create a program that calculates sales commission for salespeople by taking gross sales as input and outputting earnings using a function. The second asks to write a function that checks if a number is prime and prints the result. The third asks to create a program that determines if a customer has exceeded their credit limit by taking account details as input and calling a function to calculate the new balance and check against the limit.

Uploaded by

cleophacerevival
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSU07207/ ITU07207 – Procedural Programming

Lab Exercises 5.
1. (Sales-Commission Calculator) Chakubanga chemical company pays its
salespeople on a commission basis. The salespeople receive TZS 200,000/= per
week plus 9% of their gross sales for that week. For example, a salesperson who
sells TZS 5,000,000/= worth of chemicals in a week receives TZS 200,000/= plus
9% of TZS 5,000,000/=, or a total of TZS 650,000/=. Develop a program that will
use scanf to input each salesperson’s gross sales for last week and display that
salesperson’s earnings. The program uses a function called "salesCommission"
which takes the gross sales as input and returns the earnings. Process one
salesperson's figures at a time. Here is a sample input/output dialog:
Enter sales in dollars (-1 to end): 5000000.00
Salary is: TZS 650000.00

Enter sales in dollars (-1 to end): 1234000.56


Salary is: TZS 311110.00

Enter sales in dollars (-1 to end): -1

2. (Prime Number Function) Write a C program that defines a function called


"isPrime" which takes an integer as input and returns 1 if the number is prime, and
0 otherwise. Use this function to check and print whether a number entered by the
user is prime or not.
3. (Credit-Limit Calculator) Develop a C program that will determine whether a
department-store customer has exceeded the credit limit on a charge account. For
each customer, the following facts are available:
a. Account number
b. Balance at the beginning of the month
c. Total of all items charged by this customer this month
d. Total of all credits applied to this customer's account this month
e. Allowed credit limit
The program should use scanf to input each fact. The program uses a function called
“limitExceeded” to calculate the new balance (= beginning balance + charges –
credits), and determine whether the new balance exceeds the customer's credit limit.
For those customers whose credit limit is exceeded, the program should display the
customer's account number, credit limit, new balance and the message “Credit limit
exceeded.” Here is a sample input/output dialog:
Enter account number (-1 to end): 100
Enter beginning balance: 5394.78
Enter total charges: 1000.00
Enter total credits: 500.00
Enter credit limit: 5500.00
Account: 100
Credit limit: 5500.00
Balance: 5894.78
Credit Limit Exceeded.

Enter account number (-1 to end): 200


Enter beginning balance: 1000.00
Enter total charges: 123.45
Enter total credits: 321.00
Enter credit limit: 1500.00

Enter account number (-1 to end): 300


Enter beginning balance: 500.00
Enter total charges: 274.73
Enter total credits: 100.00
Enter credit limit: 800.00

Enter account number (-1 to end): -1

You might also like