Professional Documents
Culture Documents
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 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
Step 1: Start
Number 3:
Algorithm Pseudocode
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.
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