0% found this document useful (0 votes)
12 views3 pages

Programming Worksheet 2

Uploaded by

xavier.hawes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Programming Worksheet 2

Uploaded by

xavier.hawes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

COMPUTING & INFORMATION TECHNOLOGY

Programming 1: Tutorial/Practical Worksheet #2

A. Develop Truth Tables for AND, OR and NOT operators.

Input X Input Y X AND Y X OR Y NOT X


True True True True False
True False False True False
False True False True True
False False False False True

B. Evaluate the following arithmetic expressions


1. 7 + 3 * 2 – 7 / 2
9.5
2. (20 + 3) + 12 + 8 / 4 * 3
41
3. 15 / 3 * 2 + 3
13
4. 19 % 4 + 15 / 2 * 3
25.5
5. (3 + 4) * 6 / 3
14
6. 30/(5+1)∗2
10
7. (20−8)/4+(12/3)
7
8. (25−3∗6)+(28/4)
14
9. (40/(5+5))∗(18%7)+6
22
10. ((12−4)∗(6/3))+(50%9)
21

C. Evaluate the following logical expressions (True/False):


1. (10 > 6) AND (4 < 9)
True
2. (7 == 5) OR (12 > 8)
True
3. (15 / 3 == 5) AND (20 % 3 == 2)
1
True
4. (18 < 10) OR (6 * 2 == 12)
True
5. NOT (8 > 3)
False
6. (25 % 6 == 1) AND (14 / 2 > 5)
True
7. (9 <= 9) OR (7 > 10)
True
8. (3 + 4 < 10) AND (2 * 3 != 7)
True
9. (20 / 4 == 5) AND NOT (12 < 8)
True
10. (30 % 4 == 2) OR (5 * 3 < 12)
True

D. Based on the IPO charts created last week for the questions listed below, please
convert each solution into both pseudocode and a corresponding flowchart.

1. Calculate the perimeter of a rectangle.


2. Calculate the Simple Interest of a given principal. (Formula: SI = Principal × Rate
× Time / 100)
3. Calculate the volume of a cylinder. (Volume = π × radius² × height)
4. A company pays employees a basic salary. Each employee also receives a housing
allowance = 20% of basic salary and a transport allowance = 10% of basic
salary. Calculate the gross salary.

2
5. Calculate the final bill for a meal. The program should take the meal's subtotal and
calculate the tax (10%) and a tip (15% of the subtotal). The final bill is the sum
of the subtotal, tax, and tip.
6. A store gives a 15% discount on the cost of items. Read the total cost of an item
purchased, calculate the discount amount and the final price after discount.
7. A student’s final score is calculated as follows:
a. Assignments = 20% of total
b. Midterm Exam = 30% of total
c. Final Exam = 50% of total
Read the three scores and calculate the final weighted score.
8. A car rental company charges a daily rate of $5000 for each rental. An insurance fee
of $1000 is charged per day and service tax of 12% of total charges are added. Read
the number of days rented and calculate the final amount to pay.
9. A university charges students tuition and other fees as follows:
a. Tuition fee = number of credits per credit
b. Registration fee = $5,000 (fixed)
c. Library fee = $2,000 (fixed)
d. Technology fee = 8% of tuition fee
e. Development fee = 5% of tuition fee
Design an IPO chart to calculate and display the total university fee for a student,
given the number of credits and the cost per credit.

In the Laboratory
 Complete any unfinished questions from the previous sections.
 Your tutors should introduce the phases associated with implementing a C program:
creating source code, compiling, the C preprocessor with preprocessor directives, linking,
and loading. This should be accompanied by a walkthrough of the basic program
structure before students begin writing complete source code.

You might also like