Asked by Anonymous

Create the logic for a program that continuously prompts a user for a numeric value until the user enters 0. The application passes the value in turn to a method that squares the number and to a method that cubes the number. The program displays the results before reprompting the user. Create the two methods that square and cube a number passed to them, and then return the calculated value.

Answers

Answered by Steve
square(n) {
return n*n
}

cube(n) {
return n*n*n
}

Loop
prompt "n: "
read n
exit loop if n == 0
s = square(n)
c = cube(n)
print n,s,c
end loop

Related Questions