C语言 奶茶铺 大杯奶茶12元 中杯10 小杯8元 消费30打9折 设计程序 输出包含 一次性消费金额 实付 找零

C语言 奶茶铺 大杯奶茶12元 中杯10 小杯8元 消费30打9折 设计程序 输出包含 一次性消费金额 实付 找零,第1张

#include<stdio.h>

int main()

{

    int big,middle,small,pay,consumpt

    scanf("请输入大杯奶茶数量:%d",&big)

    scanf("请输入中杯奶茶数量:%d",&middle)

    scanf("请输入小杯奶茶数量: %d",&small)

    scanf("请输入实付金额:%d",&pay)

    

    consumpt = big*12+middle*10+8*small

    printf("消费金额:%d ",consumpt  > 30? consumpt*0.9:consumpt)

    printf("实付:%d 。找回:%d ",pay,pay -(consumpt  > 30? consumpt*0.9:consumpt))

    return 0

    

    

}

C#程序如下

using System

namespace productApplication{

class Product{

static void Main(string[] args){

Console.WriteLine("奶茶单价5.5")

Console.WriteLine("黄焖鸡单价9.5")

Console.WriteLine("请输入它们的份数(以空格分隔):")

string s=Console.ReadLine()

string[] str=s.Split(' ')

double sum=0

sum=Convert.ToInt32(str[0])*5.5

sum=sum+Convert.ToInt32(str[1])*9.5

Console.WriteLine("总价为:{0}",sum)

Console.ReadKey()

}

}

}

#include<stdio.h>

#include<conio.h>

main()

{

int i=1

char getchviewk

for( i =1i<=5i++)

{

printf("[1]可乐 [2]咖啡\n")

printf("[3]果汁 [4]奶茶\n")

printf("[0]退出\n")

if(i==1)getchviewk=getch()

switch(getchviewk)

{

case 48 : i=5break

case 49 :printf("可乐3元\n")getchviewk=getch()break

case 50 :printf("咖啡5元\n")getchviewk=getch()break

case 51 :printf("果汁4元\n")getchviewk=getch()break

case 52 :printf("奶茶2元\n")getchviewk=getch()break

default : printf("显示错误提示信息\n")getchviewk=getch()

}

system("cls")

}

return 0

}


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

原文地址:https://54852.com/yw/7727674.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存