Professional Documents
Culture Documents
ITP Activity No.2
ITP Activity No.2
ITP Activity No.2
Week No. 2
ALGORITHM AND PSEUDOCODE
Number 1:
Instructions: Write the Algorithm and Pseudocode of the following problem:
Process:
Input :
Perform a
Asks the user to calculation to get
input the list the selling price.
price, discount (PROCESS).
and tax (INPUT)
Output:
Display the
calculated selling
price.
(OUTPUT).
Week No. 2
ALGORITHM AND PSEUDOCODE
Number 1:
Algorithm Pseudocode
Step 2: Declare variables list price, DECLARE list price, discount, tax
discount, tax
READ list price, discount, tax
Step 3: Read input from the user
Selling price = (list price –
Step 4: Calculate the selling price: discount) + tax
Selling price = (list price –
discount) + tax DISPLAY Selling price
Step 6: Stop
Week No. 2
ALGORITHM AND PSEUDOCODE
Number 2:
2. The volume of a rectangular box is given by the formula, V = length *
width * height. Calculate and display the Volume of a box whose dimensions
are specified by the user.
Process:
Input :
Perform a calculation to
Asks the user to get the volume of a
input the length, rectangle according to the
width and height. measurements of inputted
(INPUT) by the user . (PROCESS).
Output:
Display the
calculated volume
of the rectangle
box. (OUTPUT).
Week No. 2
ALGORITHM AND PSEUDOCODE
Number 2:
Algorithm Pseudocode
Step 6: Stop
Week No. 2
ALGORITHM AND PSEUDOCODE
Number 3:
3. An automobile is used for travelling purposes. Write the algorithm and
pseudocode that will ask the value of distance travelled in miles, the total
gallons of fuel used, the cost of fuel, the amount of other expenses, and then
output the miles per gallon, the cost per mile and the total cost of the trip.
Process:
Input : Perform a calculation of the
record for each truck and for
Asks the user (truck driver) for each trip the miles per gallon,
the data needed; distance traveled the total cost of the trip and the
(miles), number of gallons of fuel cost per mile. (PROCESS).
used, cost of the fuel, and other
cost of operating the truck.
(INPUT).
Output:
Display and record the
calculation in the database
of the manufacturing
company. (OUTPUT).
Week No. 2
ALGORITHM AND PSEUDOCODE
Number 3:
VARIABLES : distance traveled (miles), number of gallons of fuel used,
cost of the fuel, and other cost of operating the truck.
FORMULA :
miles per gallon = distance traveled (miles) / number of galloons of
fuel used
total cost of the trip = (number of galloons of fuel used * cost of
fuel) + other cost of operating the truck,
cost per mile = total cost of the trip / distance traveled (miles)
Algorithm Pseudocode
Number 3:
Algorithm Pseudocode
Number 4:
4. A supermarket sells bags of mixed candies. Four types of candies are for sale.
Candy A costs P42.50/kg; Candy B, P35.75/kg; Candy C, P49.50/kg; and Candy D,
P30.50/kg. Calculate and print the amount of a bag of candies in terms of the
weights of each type of candy as provided by the user.
Process:
Input :
Perform a calculation to
Asks the user to get the amount of a bag of
input the type of candies based on the input
candy and weight of the user. (PROCESS)
(kg). (INPUT)
Output:
Display the calculated
amount of a bag of
candies based on the
input of the user
(OUTPUT).
Week No. 2
ALGORITHM AND PSEUDOCODE
Number 4:
VARIABLES : type of candy, and weight (kg)
FORMULA : type of candy * weight (kg)
Price per type of candy:
Candy A = P 42.50 Candy C = P 49.50
Candy B = P 35.75 Candy D = P 30.50
Algorithm Pseudocode
Step 1: Start START
DISPLAY the price per type of
Step 2: Display the price per each candy
type of candy candy A= P 42.50,candy B=P 35.75
candy C= P 49.50,candy D=P 30.50
Step 3: Declare variables type of
candy, and weight (kg) DECLARE type of candy, and
weight (kg)
Step 4: Read input from the user READ type of candy, and weight
(kg)
Step 5: Calculate the amount of a
bag of candies based on the input CASE type of candy OF
of the user 'A', 'a' : weight * 42.50
amount of a bag of candies 'B', 'b' : weight * 35.75
based on the input of the 'C', 'c' : weight * 49.50
user = type of candy * weight 'D', 'd' : weight * 30.50
ENDCASE
Step 6: Display the amount of a
bag of candies based on the input DISPLAY amount of a bag of
of the user candies based on the input of the
user
Step 7: Stop STOP