Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Programming Fundamentals

Theory(CS-116T)
Assignment #2

Name: Muhammad Aaman Khan


Department: BS Computer Science
Section: A
Roll no: 2022F-BSCS-017
Question 1:
You are an accountant setting up a payroll system based on Table,
which shows five different ranges for salaries up to Rs.150, 000.00. Each
table line shows the base tax amount (column2) and tax percentage
(column3) for a particular salary range (column1).

Write a function that taken person’s salary and calculate the tax due by
adding the base tax to the product of the percentage times the excess
salary over the minimum salary for that range.

Source Code:
Output:
Question 2:
A parking garage charges a $2.00 minimum fee to park for up to
three hours. The garage charges an additional $0.50 per hour
for each hour or part thereof in excess of three hours. The
maximum charge for any given 24-hour period is $10.00.
Assume that no car parks for longer than 24 hours at a time.
Write a program that calculates and prints the parking charges
for each of three customers who parked their cars in this
garage yesterday. You should enter the hours parked for each
customer. Your program should print the results in a neat
tabular format and should calculate and print the total of
yesterday’s receipts. The program should use the function
calculateCharges to determine the charge for each customer.
Your outputs should appear in the following format:

Source Code:
Output:
Question 3:
Show the value of x after each of the following statements is
performed:

a) x = fabs( 7.5 )
b) x = floor( 7.5 )
c) x = fabs( 0.0 )
d) x = ceil( 0.0 )
e) x = fabs( -6.4 )
f) x = ceil( -6.4 )
g) x = ceil( -fabs( -8 + floor( -5.5 ) ) )

a) x = fabs( 7.5 )
Source Code:

Output:

b) x = floor( 7.5 )
Source Code:

Output:
c) x = fabs( 0.0 )
Source Code:

Output:

d) x = ceil( 0.0 )
Source Code:

Output:

e) x = fabs( -6.4 )
Source Code:

Output:
f) x = ceil( -6.4 )
Source Code:

Output:

g) x = ceil( -fabs( -8 + floor( -5.5 ) ) )


Source Code:

Output:

You might also like