user1825706
user1825706

Reputation: 11

In function ‘Calculate_Duty’: error: nested functions are disabled, use -fnested-functions to re-enable

include

/* Declare function prototypes */

float Calculate_Duty (int, int);

void Print_Duty (float);

int main (void)

{

/* Declare all variables to be used in the program */

char more_to_process;

int origin, category, quantity, num_ship=0;

float unit_price;

float cost, duty, total_ship=0;

float total_duty=0, tax_rate=0;

/* Begin to execute the program */

printf("Do you have more customs forms to process? Type: Y for yes or N for no \n");

scanf(" %c", &more_to_process);

while ((more_to_process =='Y') && (more_to_process!='N'))

{

printf ("What is the origin of the goods? Type: 1 for US, 2 for China, 3 for Brazil \n");

scanf ("%d", &origin);

printf ("What category of goods? Type: 1 for food, 2 for clothing, 3 for wood \n");

scanf ("%d", &category);

printf ("What is the quantity? \n");

scanf ("%d", &quantity);

printf ("What is the unit price? \n");

scanf ("%f", &unit_price);

total_ship= quantity * unit_price;

/* Calculate the duty of the shipment */

tax_rate= Calculate_Duty (origin, category);

duty= tax_rate * total_ship;

total_duty+= duty;

/* Print the duty of the shipment */

printf ("Origin \t Category \t Quantity \t Unit Price \t Shipment \t Tax Rate \t Duty \t \n");

printf ("%d \t %d \t \t %d \t \t %02.f \t \t %0.2f \t %0.2f \t \t %0.2f \t \n", origin,

category, quantity, unit_price, total_ship, tax_rate, duty);

Print_Duty (duty);

printf ("Do you have more customs forms to process? Type: Y for yes, N for no \n");

scanf (" %c", &more_to_process);

++num_ship;

}

printf ("Transaction Summary: \n");

printf ("Number of Shipments Processed = %d \n", num_ship);

printf ("Total Duties Collected = $ %0.2f \n", total_duty);

return 0;

}

/* Perform the function Calculate_Duty */

float Calculate_Duty (int origin, int category)

{

float duty;

switch (origin)

{

/* Case 1 is for US */

case 1:

switch (category)

{

case 1:

duty=0;

break;

case 2:

duty= 0;

break;

case 3:

duty= .05;

break;

}

break;

/* Case 2 is for China */

case 2:

switch (category)

{

case 1:

duty= .02;

break;

case 2:

duty= .03;

break;

case 3:

duty= .04;

break;

}

break;

/* Case 3 is for Brazil */

case 3:

switch (category)

{

case 1:

duty= .01;

break;

case 2:

duty= .02;

break;

case 3:

duty= .08;

break;

}

return duty;

}

/* Perform the Print_Duty function */

void Print_Duty (float duty)

{

printf ("The amount due is $ %0.2f \n", duty);

}

Upvotes: 1

Views: 75

Answers (1)

emil
emil

Reputation: 1700

As I can see one } is missing from switch(origin), before return duty.

Upvotes: 0

Related Questions