以下是引用TonyDeng在2013-2-25 20:42:11的发言:
第一个就是楼主问的,过年前,我连代码都给了,又问第二次,先前没发觉,后来查一查他的主帖记录才记起。
之前问的是快餐店菜单设计,这次不一样,要求也有所不同。下面是我写的,错误提示总是说scanf("%c", &yn1);不行,请大侠帮忙。
#include<stdio.h>
/* The purpose of this program is
to perform calculations with functions and pointers.*/
main()
{
int hqty, rqty, mqty, tqty, hwsize, rwsize, mwsize, twsize, total_sold;
double hseats, tseats, rupgrade, mupgrade, tupgrade;
double htotal, rtotal, mtotal, ttotal, total, discount, tax, total_order, total_value;
int yyyy, mm, dd;
char yn='Y';
while (yn=='Y'||yn=='y')
{
printf("\nCROWN BICYCLE CORPORATION – Manager");
printf("\nCROWN BICYCLE CORPORATION
DATE: %4d/%02d/%02d", yyyy/mm/dd);
get_inputs(&hqty, &rqty, &mqty, &tqty, &hwsize, &rwsize, &mwsize, &twsize, &hseats, &tseats, &rupgrade, &mupgrade, &tupgrade);
htotal=hqty*1000+(hwsize-22)*50+hseats;
rtotal=rqty*1000+(rwsize-22)*50+rupgrade;
mtotal=mqty*1000+(mwsize-22)*50+mupgrade;
ttotal=tqty*1000+(twsize-22)*50+tseats+tupgrade;
total=htotal+rtotal+mtotal+ttotal;
if (total>2000)
{discount=total*0.05;
tax=(total-discount)*0.13;
total_order=total-discount+tax;
printf("\nTOTAL PRICE FOR BIKE %10.2lf$\n", total);
printf("\nDISCOUNT %10.2lf$", discount);
printf("\nTAX (13% GST) %10.2lf$", tax);
printf("\nTOTAL ORDER %10.2lf$", total_order);
}
else
{
printf("\nTOTAL PRICE FOR BIKE %10.2lf$", total);
printf("\nTAX (13% GST) %10.2lf$", total*0.13 );
printf("\nTOTAL ORDER %10.2lf$", total*1.13);
}
printf( "\nWould you like to take another order? Y/N\n ");
scanf ("%c", &yn);
if(getchar()=='n')
break;
}
total_sold=hqty+rqty+mqty+tqty;
total_value+=total;
printf("\nSUMMARY for %4d/%02d/%02d", yyyy/mm/dd);
printf("\nTotal number of bikes sold: %d", total_sold);
printd("\nTotal value of bikes sold:%10.2lf", total_value);
}
get_inputs(int *hqty, int *rqty, int *mqty, int *tqty, int *hwsize, int *rwsize, int *mwsize, int *twsize,
double *hseats, double *tseats, double *rupgrade, double *mupgrade, double *tupgrade)
{
char yn1, yn2, yn3, yn4, yn5; int credit_card_number;
printf("\nBIKE MODELS – CUSTOM MADE ORDER");
printf("\nH for Hybrid-MT");
printf("\nR for Race");
printf("\nM for Mountain");
printf("\nT for Touring");
printf("\nSelect (H, R, M or T only):");
printf("\nCredit Card (last 6 numbers):%6d ", credit_card_number);
printf("\n Your Order for H:");
scanf("%d", &hqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &hwsize);
printf("\nDo you want the more comfortable seats? This charge is $50. Please enter your choice? yn1")
scanf("%c", &yn1);
if (yn1=='Y'||yn1=='y')
*hseats=50.00;
else
*hseats=0;
printf("\n Your Order for R");
scanf("%d", &rqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &rwsize);
printf("\nDo you want the upgraded custom gears? This charge is $300. Please enter your choice? yn2")
scanf("%c", &yn2);
if (yn2=='Y'||yn2=='y')
*rupgrade=300.00;
else
*rupgrade=0;
printf("\n Your Order for M");
scanf("%d", &mqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &mwsize);
printf("\nDo you want the upgraded custom gears? This charge is $300. Please enter your choice? yn3");
scanf("%c", &yn3);
if (yn3=='Y'||yn3=='y')
*mupgrade=300.00;
else
*mupgrade=0;
printf("\n Your Order for t");
scanf("%d", &tqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &twsize);
printf("\nDo you want the more comfortable seats? This charge is $50. Please enter your choice? yn4");
scanf("%c", &yn4);
if (yn4=='Y'||yn4=='y')
*tseats=50.00;
else
*tseats=0;
printf("\nDo you want the upgraded custom gears? This charge is $300. Please enter your choice? yn5");
scanf("%c", yn5);
if (yn5=='Y'||yn5=='y')
*tupgrade=300.00;
else
*tupgrade=0;
}