0% found this document useful (0 votes)
104 views3 pages

Pseudocode

This program calculates the total cost of carpeting a land area based on the shape of the land and selected carpet type. It begins by displaying introductory information and getting user input for the land shape. It then calculates the land area based on the shape. Next, it gets the price per square unit for a selected carpet type. Finally, it calculates and displays the total carpeting cost by multiplying the land area by the carpet price per unit.

Uploaded by

api-340150286
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views3 pages

Pseudocode

This program calculates the total cost of carpeting a land area based on the shape of the land and selected carpet type. It begins by displaying introductory information and getting user input for the land shape. It then calculates the land area based on the shape. Next, it gets the price per square unit for a selected carpet type. Finally, it calculates and displays the total carpeting cost by multiplying the land area by the carpet price per unit.

Uploaded by

api-340150286
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

// main module

Module main()
Call intro()
Declare String landShape
Declare Real landArea, pricePerSqUnit, totalPrice
Set landShape = getShape()
Set landArea = getArea(landShape)
Set pricePerSqUnit = getPrice()
Set totalPrice = calcPrice(landArea, pricePerSqUnit)
Display The area of the land is , landArea, sq. ft.
Display The total cost for carpeting the land area is $, totalPrice
End Module

// Intro module
Module intro()
Display This program takes a shape of the land and calculates its area. You can also
select a carpet from the following options and the program will return the total cost for carpeting
the given land area. (Unit of all lengths entered should be ft.)
Display Cost for carpet A is $1.2 per sq. ft.
Display Cost for carpet B is $3.5 per sq. ft.
Display Cost for carpet C is $7 per sq. ft.
End Module

// Function to get shape


Function String getShape()
Declare String shape
Display Enter the name of the shape of the land:
Input shape
While toLower(shape) != circle AND toLower(shape) != rectangle AND
toLower(shape) != square AND toLower(shape) != triangle
Display The shape entered is not included in the program.
Display Enter the name of the shape of the land again:
Input shape
End While

Return shape
End Function

//Function to calculate area


Function Real getArea(String shape)
Declare Real area
If toLower(shape) == circle
Declare Real radius
Declare Real pi = 3.14
Display Enter the radius of the circle:
Input radius
Set area = pi * radius ^ 2
Else If toLower(shape) == rectangle
Declare Real length, width
Display Enter the length of the rectangle:
Input length
Display Enter the width of the rectangle:
Input width
Set area = length * width
Else If toLower(shape) == square
Declare Real side
Display Enter of side length of the square:
Input side
Set area = side ^ 2
Else
Declare Real base, height
Display Enter the base of the triangle:
Input base
Display Enter the height of the triangle:
Input height
Set area = (base * height) / 2
End If
Return area
End Function

// Function to get the price of carpeting per sq unit


Function Real getPrice()
Declare String name
Declare Real price
Display Enter the name of the carpet selected:
Input name
While toLower(name) != a AND toLower(name) != b AND toLower(name) != c
Display The carpet name entered is not included in the program.
Display Enter the another carpet name:
Input name
End While
If toLower(name) == a Then
Set price = 1.2
Else If toLower(name) == b Then
Set price = 3.5
Else
Set price = 7
End If
Return price
End Function

//Function to calculate total price of carpeting


Function Real calcPrice(Real area, Real price)
Declare Real total
Set total = area * price
Return total
End Function

You might also like