In: Computer Science
A construction company has 3 categories of casual
workers. Category A,B and C. Workers in categories A are paid 1000
per day for first 25 days, you are paid 800 per day for less than
25 days, any extra day after 25th you are paid 1200 per day. In
categorie B you are paid 800 per day if you work for 25 days
otherwise you are paid 600 per day if you work for less than 25
days . 1000 per day for any day after 25th.
Category C 600 per day for 25 days , 400 per day for days before 25
days and 800 per day for days after 25th day
Question
1.write an algorithm
2. Translate to flowchart
3. Translate into actual program using language of your choice
If you have any doubts please comment below. As per the chegg honour code I did one of three.
Python Code :
# ask user for the category
type = input('Enter Category (A or B or C): ').upper()
# ask user for the number of days worked
days = int(input('Enter the number of days worked: '))
# create a variable to store the salary
salary =0
# check if the category is of type A
if type =='A':
if days<=25:salary = days*800
else: salary = 25*1000 + (days-25)*1200
# check if the category is of type B
elif type =='B':
if days<=25:salary = days*600
else: salary = 25*800 + (days-25)*1000
# check if the category is of type C
elif type=='C':
if days<=25:salary = days*400
else: salary = 25*600 + (days-25)*800
# print the salary at the end
print('Total Salary Earned:$',salary)