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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 1CP
icon
Related questions
Question

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
as you chose.

Please use pseudocode to display your answer.
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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT