Question: Program09.c:31:29: error: invalid operands to binary expression ('double' and 'double (*)(double, double, double)') fpSubtotal = unitPrice * fpUnits; Program09.c:67:44: error: invalid operands to binary expression

Program09.c:31:29: error: invalid operands to binary expression ('double' and 'double (*)(double, double, double)') fpSubtotal = unitPrice * fpUnits;

Program09.c:67:44: error: invalid operands to binary expression ('double' and 'double (*)(double, double, double)') disSubtotal = unitPrice * (1-discount) * disUnits;

#include

double fpUnits(double unitsSold, double unitPrice, double discountThr) {

double fpUnits;

if(unitsSold > discountThr) { fpUnits = discountThr; return fpUnits; } else { fpUnits = unitsSold; return fpUnits; } }

double fpSub(double unitsSold, double unitPrice, double discountThr) {

double fpSubtotal;

if(unitsSold > discountThr) { fpSubtotal = unitPrice * fpUnits; return fpSubtotal; } else { fpSubtotal = unitPrice * unitsSold; return fpSubtotal; } }

double disUnits(double unitsSold, double unitPrice, double discountThr) {

double disUnits;

if(unitsSold > discountThr) { disUnits = (unitsSold - discountThr); return disUnits; } else { disUnits = 0; return disUnits; } }

double disSub(double unitsSold, double unitPrice, double discountThr, double discount) {

double disSubtotal;

if(unitsSold > discountThr) { disSubtotal = unitPrice * (1-discount) * disUnits; return disSubtotal; } else { disSubtotal = 0; return disSubtotal; } }

int main(){

printf(" \tWelcome to Johnny's Online Candy Store "); printf("--------------------------------------------------------- ");

printf("Retailer...... ");

double price1, price2, number1, number2; char candy1[100], candy2[100];

printf("Please enter the name of first Candy: "); scanf("%s", candy1);

printf("Please enter the price (per unit) of %s : ", candy1); scanf("%lf", &price1);

printf("Please enter the name of second Candy: "); scanf("%s", candy2);

printf("Please enter the price (per unit) of %s : ", candy2); scanf("%lf", &price2);

printf(" Consumer...... ");

printf("Enter number of units of %s to purchase: ", candy1); scanf("%lf", &number1);

printf("Enter number of units of %s to purchase: ", candy2); scanf("%lf", &number2);

double fU1, fS1, dU1, dS1, fU2, fS2, dU2, dS2;

fU1 = fpUnits(number1, price1, 20); fS1 = fpSub(number1, price1, 20); dU1 = disUnits(number1, price1, 20); dS1 = disSub(number1, price1, 20, 0.1);

fU2 = fpUnits(number2, price2, 20); fS2 = fpSub(number2, price2, 20); dU2 = disUnits(number2, price2, 20); dS2 = disSub(number2, price2, 20, 0.1);

double discPrice1, discPrice2;

discPrice1 = price1*0.9; discPrice2 = price2*0.9;

printf(" Order Summary...... ");

printf("\tCandy\t\t\tUnits\t Price/Unit\t Cost "); printf("------------------------------------------------------------------- "); printf(" full price of %s\t\t %.2f\t $%.2f\t$%.2f ", candy1, fU1, price1, fS1); printf(" discounted price of %s\t %.2f\t $%.2f\t$%.2f ", candy1, dU1, discPrice1, dS1); printf(" full price of %s\t\t %.2f\t $%.2f\t$%.2f ", candy2, fU2, price2, fS2); printf(" discounted price of %s\t %.2f\t $%.2f\t$%.2f ", candy2, dU2, discPrice2, dS2); printf(" ------------------------------------------------------------- ------ ");

double totalCost, totalTax, grandTotal;

totalCost = fS1 + dS1 + fS2 + dS2; totalTax = totalCost*0.05; grandTotal = totalCost + totalTax;

printf("Total order cost $%.2f ",totalCost); printf("Total order tax $%.2f ",totalTax);

printf("Order Grand-total $%.2f ",grandTotal);

return 0;

}

Above part is my error and below is my original code. I don't know why those binary expression error happen. I'm new to C, so I'm lost a bit here. Please help, Thanks!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!