说明:设置冷冻酸奶的金额。大人会按一定比例给孩子吃。每盎司酸奶是 0.49。出于某种原因,这不起作用,我不知道为什么。我知道哪一行造成了麻烦,我用粗体和斜体表示。
#include <stdio.h>
# define SALES_TAX 0.065
# define PRICE_PER_OZ 0.49
int main()
{
float totalcash;
double ratio;
double totalbeforetax;
float totalounces;
double adultounces;
double childounces;
//user input for total cash and scanning
printf("How many dollars do you have for frozen yogurt?\n");
//scan in total cash
scanf("%f", &totalcash);
//user input for ratio and scanning
printf("What is the ratio of yogurt that you'll get to your child?\n");
//scan in ratio
scanf("%lf", &ratio);
//solve for values
totalbeforetax = (totalcash)/(1+SALES_TAX);
totalounces = totalbeforetax/(PRICE_PER_OZ);
//adultounces = childounces*ratio;
***adultounces = (totalounces-adultounces)*(ratio);***
// childounces = adultounces/ratio;
childounces = totalounces-adultounces;
//output
printf("You will get %.2lf ounces of yogurt.\n",adultounces);
printf("Your child will get %.2lf ounces of yougrt\n", childounces);
return 0;
}