You are on page 1of 2

Rajarata University of Sri Lanka

Faculty of Applied Sciences

ICT 1402 – Principles of Program Design and Programming

Practical 3
Data types,Variables,Equations, If /Else

01. Write a program that print any two integer numbers, three decimal numbers (use float) and
four characters.

02. Write a program that enters any two numbers and get their average. (Use key board inputs)

03. Write a program that print this output


m=44 and n=77
[Note: this n=77 is get by using n=m+33]

04. Write a program that converts inches to centimeters. For example, if the user enters 16.9 for a
Length in inches, the output would be 42.926cm.
(Hint: 1 inch = 2.54 centimeters)

05. Given as input an integer number of seconds, print as output the equivalent time in hours,
minutes and seconds. Recommended output format is something like:
7322 seconds is equivalent to 2 hours 2 minutes 2 seconds.

06. Write and run a program that prints the sum, difference, product, quotient and remainder of
two integers. Take values for the integers from the keyboard.
[Hint: quotient = (m/n) and remainder = (m%n)] .

07. Write a program to calculate net salary for an Employee.


Hint: Gross salary = Worked hours* Hourly rate
Total EPF = Employee Contribution + Company Contribution
Employee Contribution = 10% of Gross Salary
Company Contribution = 15% of Gross Salary
Net Salary = Gross Salary - Total EPF

1
Control Structures (if - else)

if(condition)
Statement
else(condition)
statement

1. Write and run a program that reads the user’s age and then prints
a. You are a Child. - If the age<18
b. You are a Senior citizen-If age>=18

2. Write and run a program that reads the user’s age and then prints
a. You are a Child. - If the age<18
b. You are an Adult-If18<=age<65
c. You are a Senior citizen- If age>=65

3. The marks (M1, M2, M3) obtained by a student in 3 different subjects are input through the
keyboard. The students are categorized as per the following rules.
a. Average above or equal to 75-A
b. Average between 55 and 74 – B
c. Average between 40and 54-C
d. Average below 40-F

4. Write and run a program that simulates a simple calculator. It reads two integers and a
character.
a. If the character is a +, the sum is printed;
b. If it is a -, the difference is printed;
c. If it is a *, the product is printed;
d. If it is a /, the quotient is printed
e. If it is a %, the remainder is printed

5. A company insures its drivers in the following


cases
a. If the driver is married
b. If the driver is unmarried male and above 30 years of age
c. If the driver is unmarried, female and above 25 years of age
Read age, sex and marital status through the keyboard and output whether the driver is insured or
not

You might also like