求大神帮我写下这个C语言程序 把源代码回复给我 谢谢了!
1.Thedollarchangeremainingafteranamountpaidisusedtopayarestaurantbillofamountcheckcan...
1. The dollar change remaining after an amount paid is used to pay a
restaurant bill of amount check can be calculated using the following C
statements:
/* determine the amount of the change */
change = (paid - check) * 100;
/* determine the number of dollars in the change */
dollars = change / 100;
…
(1). Using the previous statements as a starting point, write a C program
that calculates the number of dollar bills(100 cents), quarters coins(25
cents), dimes coins (10 cents), nickels coins (5 cents), and pennies coins (1
cents) in the change when $10 is used to pay a bill of $6.07.
(2) Using the C program to calculate the change when a check of $12.36
is paid using a $20 bill. 展开
restaurant bill of amount check can be calculated using the following C
statements:
/* determine the amount of the change */
change = (paid - check) * 100;
/* determine the number of dollars in the change */
dollars = change / 100;
…
(1). Using the previous statements as a starting point, write a C program
that calculates the number of dollar bills(100 cents), quarters coins(25
cents), dimes coins (10 cents), nickels coins (5 cents), and pennies coins (1
cents) in the change when $10 is used to pay a bill of $6.07.
(2) Using the C program to calculate the change when a check of $12.36
is paid using a $20 bill. 展开
2个回答
展开全部
/* determine the amount of the change
change = (paid - check) * 100;
determine the number of dollars in the change
dollars = change / 100;
…
(1). Using the previous statements as a starting point, write a C program
that calculates the number of dollar bills(100 cents), quarters coins(25
cents), dimes coins (10 cents), nickels coins (5 cents), and pennies coins (1
cents) in the change when $10 is used to pay a bill of $6.07.
(2) Using the C program to calculate the change when a check of $12.36
is paid using a $20 bill.
*/
#include "stdio.h"
void getChange(int paid, float bill)
{
if (paid < bill)
{
printf("Your money cant paid for the bill!\n");
return;
}
else
{
int remain;
int dollor = 0,quarter = 0,dime = 0,nickel = 0,penny = 0;
remain = (paid*100 - bill*100)+0.5;
dollor = remain/100;
printf("Change Dollors: %d\n",dollor);
remain -= dollor*100;
quarter = remain/25;
printf("Change Quarters: %d\n",quarter);
remain -= quarter*25;
dime = remain/10;
printf("Change Dimes: %d\n",dime);
remain -= dime*10;
nickel = remain/5;
printf("Change Nickels: %d\n",nickel);
remain -=nickel*5;
penny = remain;
printf("Change Pennys: %d\n",penny);
printf("Change finished!\n");
}
}
void main()
{
int paid;
float bill;
printf("Please input your Paid($):");
scanf("%d",&paid);
printf("Please input your Bill($):");
scanf("%f",&bill);
printf("Your change is: \n");
getChange(paid, bill);
}
change = (paid - check) * 100;
determine the number of dollars in the change
dollars = change / 100;
…
(1). Using the previous statements as a starting point, write a C program
that calculates the number of dollar bills(100 cents), quarters coins(25
cents), dimes coins (10 cents), nickels coins (5 cents), and pennies coins (1
cents) in the change when $10 is used to pay a bill of $6.07.
(2) Using the C program to calculate the change when a check of $12.36
is paid using a $20 bill.
*/
#include "stdio.h"
void getChange(int paid, float bill)
{
if (paid < bill)
{
printf("Your money cant paid for the bill!\n");
return;
}
else
{
int remain;
int dollor = 0,quarter = 0,dime = 0,nickel = 0,penny = 0;
remain = (paid*100 - bill*100)+0.5;
dollor = remain/100;
printf("Change Dollors: %d\n",dollor);
remain -= dollor*100;
quarter = remain/25;
printf("Change Quarters: %d\n",quarter);
remain -= quarter*25;
dime = remain/10;
printf("Change Dimes: %d\n",dime);
remain -= dime*10;
nickel = remain/5;
printf("Change Nickels: %d\n",nickel);
remain -=nickel*5;
penny = remain;
printf("Change Pennys: %d\n",penny);
printf("Change finished!\n");
}
}
void main()
{
int paid;
float bill;
printf("Please input your Paid($):");
scanf("%d",&paid);
printf("Please input your Bill($):");
scanf("%f",&bill);
printf("Your change is: \n");
getChange(paid, bill);
}
展开全部
AO MPOP MKGAS[ PM VKVLAKOPS[ MAGKV S;IM VAI SIDOPKF;LSDKFDOPAIFOFK SFKDOIFAISFKSLD;KF;L MSDFIOPD FKS;LDFKDOPSIAOFASFSLDKVCOAPSDIFSDFOAKVCL;KFPOIAS MVAOS AOM ADSFIOSPDF FODSPKFAKLKC;LASDFIUOPSVKL;CVKPOASIDPFSDOP.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询