ITP Activity No.2

You might also like

Download as pdf or txt
Download as pdf or txt
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 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 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 length, DECLARE length, width, height


width, height
READ length, width, height
Step 3: Read input from the user
volume (rectangle) = length *
Step 4: Calculate the volume of a width * height
rectangle:
Volume(rectangular box) = DISPLAY volume (rectangle)
length * width * height
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 START

Step 2: Declare variables record DECLARE record for the distance


for the distance traveled traveled (miles), number of
(miles), number of gallons of gallons of fuel used, cost of the
fuel used, cost of the fuel, fuel, and other cost of operating
and other cost of operating the truck
the truck
READ record for the distance
Step 3: Read input from the user traveled (miles), number of
gallons of fuel used, cost of the
Step 4: Calculate the value for fuel, and other cost of operating
following: the truck
miles per gallon = distance
traveled (miles) / number of miles per gallon = distance
galloons of fuel used traveled (miles) / number of
galloons of fuel used
Week No. 2
ALGORITHM AND PSEUDOCODE

Number 3:

Algorithm Pseudocode

total cost of the trip =


total cost of the trip =
(number of galloons of fuel
(number of galloons of fuel
used * cost of fuel) + other cost
used * cost of fuel) + other cost
of operating the truck
of operating the truck
cost per mile = total cost
cost per mile = total cost of
of the trip / distance traveled
the trip / distance traveled
(miles)
(miles)

Step 5: Display the calculated


DISPLAY miles per gallon, total
miles per gallon, total cost
cost of the trip, and the cost per
of the trip, and the cost
mile
per mile
STOP
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, 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

You might also like