Algorithm Workbench
3.)
# Values for a and b
a = 10 # You can use any number for ‘a’
b = 5 # You can use any number for ‘b’
# a. Adds 2 to ‘a’ and stores the result in ‘b’
b=a+2
# b. Multiplies ‘b’ times 4 and stores the result in a’’
a=b*4
# c. Divides ‘a’ by 3.14 and stores the result in ‘b’
b = a / 3.14
# d. Subtracts 8 from ‘b’ and stores the result in ‘a’
a=b–8
-------------------------------------------------------------------------------------------------------------------------------------
4.)
a. x + y= 4 + 8=
b. z*2 = 2*2 =
c. y/x = 8/4 =
d. y – z = 8 – 2 =
a. 12
b. 4
c. 2
d. 6
------------------------------------------------------------------------------------------------------------------------------------------
5.)
Declare Real cost
Set cost to 0
------------------------------------------------------------------------------------------------------------------------------------------
6.)
Declare Integer total
Set total to 0
------------------------------------------------------------------------------------------------------------------------------------------
7.)Set count to 27
------------------------------------------------------------------------------------------------------------------------------------------
Programming Exercises
3.)
# Program to Calculate Acres from Square Feet
# Input:
# - total_square_feet (integer): the total square feet in a tract of land
# Process:
# - Get user input for total_square_feet
# - Calculate the number of acres by dividing total_square_feet by 43,560
# Output:
# - acres (float): the calculated number of acres in the tract
Pseudocode:
# Prompt user to enter the total square feet
Display "Enter the total square feet in the tract of land: "
Read total_square_feet
# Calculate the number of acres
acres = total_square_feet / 43560
# Display the result
Display "The tract of land is approximately ", acres, " acres."
7.)
# Program to Calculate Miles-Per-Gallon (MPG)
# Input:
# - miles_driven (float): the number of miles driven by the car
# - gallons_used (float): the number of gallons of gas used by the car
# Process:
# - Get user input for miles_driven and gallons_used
# - Calculate MPG using the formula: MPG = miles_driven / gallons_used
# Output:
# - mpg (float): the calculated miles-per-gallon for the car
Pseudocode:
# Prompt user to enter the number of miles driven
Display "Enter the number of miles driven: "
Read miles_driven
# Prompt user to enter the gallons of gas used
Display "Enter the gallons of gas used: "
Read gallons_used
# Calculate miles-per-gallon (MPG)
mpg = miles_driven / gallons_used
# Display the result
Display "The car's miles-per-gallon is approximately ", mpg, " MPG."