简体   繁体   English

方案:创建一个程序产品,该产品将要求两个数字并计算其乘积

[英]Scheme: Create a procedure product that will ask for two numbers and compute its product

Create a procedure product that will ask for two numbers and compute its product. 创建一个程序产品,该产品将要求两个数字并计算其乘积。 If the product is greater than or equal to 20, your program will ask for a radius in order to compute the area of a circle; 如果乘积大于或等于20,则您的程序将要求一个半径以计算圆的面积; otherwise, the program will ask for the length and width to compute the area of a rectangle. 否则,程序将要求长度和宽度以计算矩形的面积。 If the product is zero, the program will display Invalid Inputs! 如果乘积为零,程序将显示无效输入! The program should be implemented in at least two procedures. 该程序应至少以两个过程实施。

help please? 请帮助? i have this 我有这个

(define circle
  (lambda (radius)
    (* 3.14 (* radius radius)))

(define product
  (lambda (a b)
    (* a b))

You can "ask for two numbers" using read . 您可以使用read “询问两个数字”。

> (let ((a (read))) (format "You typed: ~a" a))
12
"You typed: 12"
> 

That coincidentally show you how to format output as well, though a read-through of the docs might still help with the finer points. 巧合地向您展示了如何设置输出format ,尽管对文档进行通读仍然可以帮助您解决问题。 Just remember to check if the return value is actually a number with number? 只记得检查返回值是否实际上是带有number? , and the rest of your question should be pretty self-explanatory. ,其余问题应该是不言而喻的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM