Uploaded by Gapol, Loniel Marlo M. 洛尼尔

CC-101-LEC-MT-ASSIGNMENT-1

advertisement
CC 101 LEC
MT ASSIGNMENT 1
General instructions:
a.
b.
c.
d.
Submit in legal-sized paper.
Must be handwritten. Write legibly.
Do not use AI tools such as ChatGPT
Use appropriate identifiers in your program codes.
Problem 1:
Write a program that calculates the monthly paycheck of a salesperson at a local department store.
Every salesperson has a base salary. The salesperson also receives a bonus at the end of each month, based
on the following criteria: If the salesperson has been with the store for five years or less, the bonus is $10
for each year that he or she has worked there. If the salesperson has been with the store for more than
five years, the bonus is $20 for each year that he or she has worked there. The salesperson can earn an
additional bonus as follows: If the total sales made by the salesperson for the month are at least $5,000
but less than $10,000, he or she receives a 3% commission on the sale. If the total sales made by the
salesperson for the month are at least $10,000, he or she receives a 6% commission on the sale.
To calculate a salesperson’s monthly paycheck, you need to know the base salary, the number of years
that the salesperson has been with the company, and the total sales made by the salesperson for that
month. Suppose baseSalary denotes the base salary, noOfServiceYears denotes the number of years that
the salesperson has been with the store, bonus denotes the bonus, totalSales denotes the total sales made
by the salesperson for the month, and additionalBonus denotes the additional bonus.
You can determine the bonus as follows:
if (noOfServiceYears is less than or equal to five)
bonus = 10 * noOfServiceYears
otherwise
bonus = 20 * noOfServiceYears
Next, you can determine the additional bonus of the salesperson as follows:
if (totalSales is less than 5000)
additionalBonus = 0
otherwise
if (totalSales is greater than or equal to 5000 and
totalSales is less than 10000)
additionalBonus = totalSales * (0.03)
otherwise
additionalBonus = totalSales * (0.06)
Problem 2:
Write a program that calculates and prints the bill for a cellular telephone company. The company
offers two types of service: regular and premium. Its rates vary, depending on the type of service.
The rates are computed as follows:
Regular service:
$10.00 plus first 50 minutes are free. Charges for over 50 minutes
are $0.20 per minute.
Premium service:
$25.00 plus:
a. For calls made from 6:00 a.m. to 6:00 p.m., the first 75 minutes are free; charges for more than
75 minutes are $0.10 per minute.
b. For calls made from 6:00 p.m. to 6:00 a.m., the first 100 minutes are free; charges for more than
100 minutes are $0.05 per minute.
Your program should prompt the user to enter an account number, a service code (type char), and
the number of minutes the service was used. A service code of r or R means regular service; a
service code of p or P means premium service. Treat any other character as an error. Your program
should output the account number, type of service, number of minutes the telephone service was
used, and the amount due from the user.
For the premium service, the customer may be using the service during the day and the night.
Therefore, to calculate the bill, you must ask the user to input the number of minutes the service
was used during the day and the number of minutes the service was used during the night.
Download