Green Carpet Company wants a program to compute carpet costs. The program prompts the user for two numeric values that represent room dimensions in feet. The program then displays the room area in square feet and the carpet price, which is $15 per square foot. If the user enters two positive numbers, the program will call a method that accepts two parameters and multiplies them to compute the room’s area. If just one of the entered values is positive, the program will pass the positive value to an overloaded version of the method that accepts one parameter and squares it to calculate the area. If neither of the entered values is positive, the program will display an error message. Below is the beginning pseudocode for the program. You will need to create the two methods. The two methods will have the same name (calcArea) it is just the number of arguments that will differ. You may use as many lines
Green Carpet Company wants a
numeric values that represent room dimensions in feet. The program then displays the room area in square feet
and the carpet price, which is $15 per square foot. If the user enters two positive numbers, the program will call
a method that accepts two parameters and multiplies them to compute the room’s area. If just one of the
entered values is positive, the program will pass the positive value to an overloaded version of the method that
accepts one parameter and squares it to calculate the area. If neither of the entered values is positive, the
program will display an error message.
Below is the beginning pseudocode for the program. You will need to create the two methods. The two methods
will have the same name (calcArea) it is just the number of arguments that will differ. You may use as many lines
as you chose.
Pseudocode:
start
// Declarations
num side1
num side2
num area = 0
num cost
num RATE = 15
output “Enter the room dimensions (length & width):”
input side1, side2
if length > 0 AND width > 0 then
area = calcArea(side1, side2)
else
if side1 > 0 then
area = calcArea(side1)
else
if side2 > 0 then
area = calcArea(side2)
else
output “An error has occurred, please re-enter the room dimensions.”
endif
endif
endif
if area > 0 then
output “The area is: ”, area
cost = area * RATE
output “The cost is: ”, cost
endif
return
______________________
______________________
______________________
______________________
______________________
______________________
______________________
______________________
______________________
______________________
stop
Step by step
Solved in 2 steps with 4 images