You are on page 1of 9

Name: Franc Alvenn Dela Cruz Rating: _________

Year and Section: BSIT 1-A Professor / Instructor: Herliza Estrada


Due of Submission:

Week No. 2
ALGORITHM AND PSEUDOCODE
Number 1:
Instructions: Write the Algorithm and Pseudocode of the following problem:

1. Calculate the selling price of an item at a discount store where: Selling


Price = (list price – discount) + tax. Print the value of Selling Price.

Input - Process - Output


Program to calculate the selling price.
Asks the user to input the list price, discount and tax (INPUT)
Perform a calculation to get the selling price. (PROCESS).
Display the calculated selling price. (OUTPUT).

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:

VARIABLES : list price, discount, tax


FORMULA : (list price - discount) + tax

Algorithm Pseudocode

Step 1: Start START

Step 2: Declare variables list price DECLARE LP, D, T


(LP), discount (D), tax (T)
READ LP, D, T
Step 3: Read input from the user
Selling price = (LP - D) + T
Step 4: Calculate the selling price:
Selling price = (LP - D) + T DISPLAY Selling price

Step 5: Display the calculated STOP


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.

Input - Process - Output


Program to calculate the volume of a rectangle box.
Asks the user to input the length, width and height. (INPUT)
Perform a calculation to get the volume of a rectangle according to the
measurements of inputted by the user . (PROCESS).
Display the calculated volume of the rectangle (OUTPUT).

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:

VARIABLES : length, width, height


FORMULA : volume of the rectangular box = length * width * height

Algorithm Pseudocode

Step 1: Start START

Step 2: Declare variables DECLARE L, W, H


length(L), width(W), height(H)
READ L, W, H
Step 3: Read input from the user
volume (rectangle) = L* W * H
Step 4: Calculate the volume of a
rectangle: DISPLAY volume (rectangle)
Volume(rectangular box) =
L*W*H STOP

Step 5: Display the calculated


volume (rectangle).

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.

Input - Process - Output


Program to record and calculate the miles per gallon, total cost of the trip and
the cost per mile for each truck and for each trip.
Asks the user (truck driver) for the data needed; distance traveled (miles),
number of gallons of fuel used, cost of the fuel, and other cost of operating the
truck. (INPUT).
Perform a calculation of the record for each truck and for each trip the miles
per gallon, the total cost of the trip and the cost per mile. (PROCESS).
Display and record the calculation in the database of the manufacturing
company. (OUTPUT).

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

Step 1: Start

Step 2: Declare variables record


START
for the distance traveled
(miles)(DT), number of
DECLARE DT, FU, CF, OC
gallons of fuel used (FU), cost
of the fuel(CF), and other cost
READ DT, FU, CF, OC
of operating the truck (OC)

miles per gallon = DT / FU


Step 3: Read input from the user

Step 4: Calculate the value for


following:
miles per gallon = distance
traveled (miles)(DT) / number of
galloons of fuel used (FU)
Week No. 2
ALGORITHM AND PSEUDOCODE

Number 3:

Algorithm Pseudocode

total cost of the trip = (FU *


total cost of the trip =
CF) + OC
(number of galloons of fuel
used (FU) * cost of fuel(CF)) +
cost per mile = total cost of
other cost of operating the
the trip / DT
truck(OC)
cost per mile = total cost
of the trip / distance traveled
DISPLAY miles per gallon, total
(miles)(DT)
cost of the trip, and the cost per
mile
Step 5: Display the calculated
miles per gallon, total cost
STOP
of the trip, and the cost
per mile

Step 6: Stop
Week No. 2
ALGORITHM AND 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.

Input - Process - Output


Program to calculate the amount of a bag of candies based on the input of
the user
Asks the user to input the type of candy and weight (kg). (INPUT)
Perform a calculation to get the amount of a bag of candies based on the
input of the user. (PROCESS)
Display the calculated amount of a bag of candies based on the input of the
user (OUTPUT).

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 (TC), and weight DECLARE TC, W
(kg)(W) READ TC, W(kg)
Step 4: Read input from the user
CASE type of candy OF
Step 5: Calculate the amount of a 'A', 'a' : weight * 42.50
bag of candies based on the input 'B', 'b' : weight * 35.75
of the user 'C', 'c' : weight * 49.50
amount of a bag of candies 'D', 'd' : weight * 30.50
based on the input of the ENDCASE
user = type of candy(TC)*
weight(W) DISPLAY amount of a bag of
candies based on the input of the
Step 6: Display the amount of a user
bag of candies based on the input STOP
of the user
Step 7: Stop

You might also like