Prob. Solving Phases (PSS)
Prob. Solving Phases (PSS)
Learning Outcomes
After completing this lab, you will be able to:
o describe the steps in the programming process
o construct an algorithm by using flowchart or pseudocode
o recognize syntax and logic error
A. PRE-LAB ACTIVITIES
Question 1
List the five basic steps in the programming process.
Answer
Question 2
Define an algorithm.
Answer
Question 3
Define a flowchart.
Answer
Question 4
Define a pseudocode.
Answer
Question 5
What is a syntax error?
Answer
Question 6
What is a logic error?
Answer
Question 7
What is the purpose of documentation inside a program?
Answer
Question 8
What is the symbol used to represent input/output in a flowchart?
Answer
Question 9
Ammar lives in Shah Alam that charges 3% income tax on yearly wages. He wants you
to write a program that will display the income tax. Identify the input, process and output
of this problem.
Answer
Question 10
Write a pseudocode to calculate the change given back to the customer if the customer
gives RM250.00 and the price of an item bought in the supermarket is RM206.50.
Answer
Question 11
Write a pseudocode to calculate the value of distance, in miles, giving the relationship
Giving rate is 55 miles per hour and eclipsed time is 2.5 hours.
Answer
Question 12
A finance company will give a loan to a customer for buying a car based on the amount
of a loan. If the loan is RM100,000 or more, the interest rate will be 3.5%, otherwise it
will be 5%. Given the amount of loan and the period of repayment, draw a flowchart to
calculate the amount of interest and the monthly payment or installment and display the
amount in the screen as output.
Answer
B. LAB ACTIVITIES
Exercise 1
Assume that your weight is 56 kilograms. You need to convert your weight to pound and
display it. Hint: 1 kg = 2.2 pounds.
int main()
{
float weightInKg = 56.0;
float weightInPound;
Program 2.1
Exercise 2
int main()
{
int length = 6, width = 8, perimeter, area;
Exercise 3
int main()
{
int numOfHour = 20;
float charges = 105.0;
float fees;
//Line 1
cout << “The fees is RM ” << fees; //Line 2
fees = numOfHour * charges; //Line 3
return 0;
}
Program 2.3
c. Move the statement in Line 3 to Line 1. Compile and run the program and
identify the output.
int main()
{
int numOfCD = 5;
float totalPrice;
//Line 1
cout << “The total price is RM ” << totalPrice; //Line 2
totalPrice = numOfCD * 5; //Line 3
return 0;
}
Program 2.3
c. Move the statement in Line 3 to Line 1. Compile and run the program and
identify the output.
Exercise 5
Sumayyah College charges RM105.00 for each credit hour taken by its students. The
number of hours that enrolled by a student is 20 hours. You need to calculate the fees
that the student has to pay.
Exercise 6
Your program should be able to determine whether the applicant is qualified to apply for
a credit card or not based on his salary. If the salary is greater than RM1500, then
display a message that the applicant entitles to apply. Otherwise, display a message
that the applicant cannot apply for the credit card.
a. Define the input, process and output of this task.
BilalComputer.com sell computers, software, TV’s, computer hardware, games and all
types of media such as CD, VHS, DVD and audio book. The store sells CD-RW with
RM3.50 per unit. Calculate the total price when a customer bought 5 units of CD-RW.
Student ID :
Date :
C. POST-LAB ACTIVITIES
Question 1
Question 2
Student ID :
Date :
Question 3
Question 4
Draw a flow chart to calculate an average of a series positive numbers. The process will stop if
the number entered has a negative value.
Name :
Student ID :
Date :