c程序编写一个水果店售货员算账的程序

c程序编写一个水果店售货员算账的程序,第1张

#include<stdio.h>

void main()

{

float n[4],apple=2.5,pear=1.8,banana=2,orange=1.6,price,charge,money

printf("请输入水果重量苹果 鸭梨 香蕉 橘子 (不买的水果请输入0): \n")

int i

for(i=0i<4i++)scanf("%f",&n[i])

printf("应付钱 %.2f 元\n",price=apple*n[0]+pear*n[1]+banana*n[2]+orange*n[3])

printf("请输入付款数:")scanf("%f",&money)

printf("应找钱 %.2f 元\n",money-price)

}

#include<stdio.h>

void fun(){

int i, ch float  price = 9.8, in_price, total = 0 while (1){

printf("\n1.算账模式\n2.算账\n3.退出\n")

scanf("%d", &i)

switch (i){

case 1://算账模式

{

   do{

   printf("应付款金额 %f 元.\n付款金额:", price)

   scanf("%f", &in_price)

   printf("实际付款金额%f,应找零金额 %f 元.\n", in_price, in_price - price)

   total += price

   scanf("%d", &ch)

   } while (ch != -1)

   break

}

case 2:{

   printf("收款总额:%6.2f 元.\n", total) break

}

case 3:

exit(0)

}

}

}

void main()

{

fun()

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/11831617.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存