You are on page 1of 2

Programming Exercises

1. Make a program that will compute for the midterm grade of a student. The midterm grade is
equal to one-third of the prelim exam and two-thirds of the midterm exam. Print the midterm
grade.
2. Construct a program that will compute and the print the sum and average of 3 numbers.
3. Create a program that will compute and display the Area of a rectangle using the formula
Area = Length x Width
4. Construct a flowchart that will convert and display an inputted number in inches (in.) to its
equivalent number in feet (ft). Hint 1 ft = 12 inches.
5. Make a program that accepts a number in kilowatts then display its equivalent in watts.
Hint: 1 watt = 0.001 kilowatt
6. Make a program that accepts a value for radius (R) and compute the corresponding area of a
circle. Print the value of the radius and the computed area. Use the formula Area = Pi x R2.
7. Create a program that accepts a number in square meter (m2) and display its equivalent number
in hectares (has). Hint: 1000 m2 = 1 ha
8. Read 2 records in a computer. The first record will contain unit price and the second record will
contain quantity. Make a program that will compute and display the amount by multiplying the
unit price and quantity.
9. Create a program that converts a Fahrenheit measure to a Celsius measure (C = 5/9 x (F-32)
10. Write a program that asks the user to enter the radius of a circle and then computes for its area.
Recall that the formula to compute for the area is AREA = Pi x R2 , where R is the radius. The
output must be similar to the one below

The area of the circle with radius 2 cm is 12.56 cm2

CONDITIONAL STATEMENT / SWITCH STATEMENT

11. Given two numbers X and Y, make a program to determine the difference between X and Y.
if X – Y is negative, compute R = X + Y; if X – Y is zero, compute R = 2X + 2Y; and if X – Y is
positive, compute R = X * Y;
12. Write a program that will determine and display the largest number among 3 numbers being
inputted.
13. Make a program that displays 3 inputted numbers in ascending order.
14. Create a program that asks for the amount purchased by the customer. If the customer
purchases more than 2,000 then a 5% discount is given. Display the net amount to be paid by
the customer and the discount.
15. Construct a program to determine the equivalent grade of each student in a class as follows:
a. Read in the student’s name, class standing, midterm grade, and the final exam
ratings.
b. Determine the final grade of the student by the formula: final grade = 0.30 of
midterm grade + 0.10 of class standing + 0.60 of final exam.
c. Determine the equivalent grade for the numerical value obtained by the following
grading marks:
98-100 = 4.00
95-97 = 3.75
92-94 = 3.50
89-91 = 3.25
86-88 = 3.00
83-85 = 2.75
80-82 = 2.50
77-79 = 2.25
74-76 = 2.00
71-73 = 1.75
68-70 = 1.50
64-67 = 1.25
60-63 = 1.00
Below 60 = 0.00
16. Write a program that finds the smallest among the five integers inputted by the user.
17. Write a program that computes the grade of a student using the formula:
Grade = 40% major exam + 30% average of 2 long exams + 30% average of 3 short quizzes.

Display the average of two long exams, average of 3 short quizzes and the grade of the student.
Display also a message whether the student passed or failed. Passing is 75%

18. Write a program that asks the user for the hours worked for the week and the hourly rate. The
basic salary is computed as:
Salary = hours worked * hourly rate

Bonuses are given:


No. of hours > 45 Bonus of 500 pesos
No. of hours > 40 and <=45 Bonus of 250 pesos
No. of hours >35 and <=40 bonus of 150 pesos

Display the basic salary, bonus and the total salary (basic salary + bonus) for the week.

19. Abena Company gives year-end bonus to its employees based on their number of years of
service and their salary, using the following:
Years of Service Bonus
1 10% of salary
2 to 5 20% of salary
6 to 10 50% of salary
11 and above 75% of salary

20. Write a program that accepts five numbers from the user and displays the highest and the
lowest number. Assume that there are no duplicate values.
21. Write a program that accepts three numbers from the user and displays the values from the
lowest to highest. Assume that there are no duplicate values.
22. Write a program that accepts three numbers from the user and displays the values from the
highest to lowest. Assume that there are no duplicate values.
23. Write a program segment that will ask the user if he/she wants to compute the perimeter of the
area of a triangle. If the perimeter is wanted, ask the measure of the three sides and compute
for the perimeter. If the area is wanted, ask for the measures of the base and height and
compute for the area. Display the computed value.
24. Write a program that will display “IT’S COLD!” if the temperature is less than 20, “IT’S HOT!” if
the temperature is greater than 30, “COOL CLIMATE!” otherwise.
25. Write a program that gives a discount of 100 pesos to a customer if the shirt bought is XL and
the price is greater than 500 pesos; a discount of 50 pesos if the shirt bought is L and the price is
greater than 400.
26. Write a program that will read a date (month, day and year) in integer form and display the date
in standard format.
Sample run:
Enter month: 9
Enter day: 24
Enter year: 1977

September 24, 1977

You might also like