帮忙写一个C语言程序~~~>.<(在线等,有问题请发信息给我)

来源:百度知道 编辑:UC知道 时间:2024/09/20 11:42:32
1.有4种type的文具,其价格如表1,购买的总数与打折率关系如表2.

2.允许一起购买2种以上的type.

3.最起码要体现出2种以上的函数:

1)要给出各type的金额计算函数;
2)一定要写出打折率应用的函数.

表1:
┌———┬———┐
│种类 │ 价格 │
├———┼———┤
│A type│ 5000 │
├———┼———┤
│B type│ 6000 │
├———┼———┤
│C type│ 7000 │
├———┼———┤
│D type│ 8000 │
└———┴———┘

表2:

购买总数与打折率的关系:
┌—————————————┬————┐
│ 购买的总数 │ 打折率 │
├—————————————┼————┤
│10个以上-30个(不包含30个) │ 10% │
├—————————————┼————┤
│30个以上-50个(不包含50个) │ 15% │
├—————————————┼————┤
│50个以上 │ 20% │
└—————————————┴————┘

┌————输出形态1———————————┐

请输入想要购买的文具种类和数量.

购买的文具种类:A/B/C/D

购买的数量: * * *

想要选择购买其他种类的文具吗:Yes/No

└———————————————————┘

(注释:
1.如果选择Yes,将返回 "输出形态1"框下的菜单.

2.如果选择No,则转向"输出形态2".

┌—————输出形态2—————————┐

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

void main()
{
int i, choice, type, tn, num[4], price[4], totalnum, totalprice;
double discount, discprice;

price[0] = 5000;
price[1] = 6000;
price[2] = 7000;
price[3] = 8000;

num[0] = num[1] = num[2] = num[3] = 0;

choice = 'Y';
while (choice == 'Y')
{
printf("请输入想要购买的文具种类和数量\n");
printf("购买的文具种类(A/B/C/D):");
type = 0;
while (type < 'A' || type > 'D')
{
type = getch();
type = toupper(type);
}
printf("%c\n", type);
printf("购买的数量:");
while (!scanf("%d", &tn))
{
printf("Input error, try again!");
fflush(stdin);
}
num[type - 'A'] += tn;
printf("想要选择购买其他种类的文具吗(Yes/No):"