关于制作一个加减乘除菜单(c primer plus第八章编程练习)

题目

编写一个程序,显示一个提供加法、减法、乘法、除法的菜单。获得 用户选择的选项后,程序提示用户输入两个数字,然后执行用户刚才选择的 操作。该程序只接受菜单提供的选项。程序使用float类型的变量储存用户输 入的数字,如果用户输入失败,则允许再次输入。进行除法运算时,如果用 户输入0作为第2个数(除数),程序应提示用户重新输入一个新值。该程序 的一个运行示例如下: Enter the operation of your choice:

a. add       s. subtract       m. multiply       d. divide       q. quit

 a 

      Enter first number: 22 .4

      Enter second number: one

      one is not an number.       

    Please enter a number, such as 2.5, -1.78E8, or 3: 1

       22.4 + 1 = 23.4

     Enter the operation of your choice:   

a. add        s. subtract        m. multiply       d. divide        q. quit

d     

       Enter first number: 18.4

        Enter second number: 0

        Enter a number other than 0: 0.2

       18.4 / 0.2 = 92

       Enter the operation of yo

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值