Hey guys,
Im new to the forum. Im going to school for web development and have been working on a program to calculate pricing for a made-up furniture company.
Anyway here's my code so far (sorry the txt isnt wrapped).
My question is:
The program compiles with zero errors but the math isn't calculating at all. PLEASE SOMEONE HELP! I HAVENT SLEPT ALL NIGHT
Code:#include <stdio.h> #include <stdlib.h> main() { char begin; int length=0; int width=0; int area=0; char woodtype; int drawers=0; double drawerCost=0.0; double total=00.0; double baseprice=200.00; area=width*length; \\i know this has to be wrong printf("would you like to purchase a desk (y)es or (n)o"); scanf(" %c", &begin); if (begin=='n') { printf("please reconsider a desk in the future\n"); return 0; } else if (begin=='y') { printf("Lets Begin!\n\n"); } else { printf("INVALID ENTRY!\n\n"); } printf("Please enter width\n\n"); scanf("%d", &width); printf("Thank you!\n\nPlease enter length\n\n"); area=width*length; scanf("%d", &length); if (area>750) \\if total area is over 750 we need to add $50.00 to the total { total=baseprice+50.00; } else { total=baseprice; } printf("Your current total is %d\n",total); \\supposed to be a subtotal printf("Desks come in three packages including three drawers, four drawers and five drawer options.\n\n"); printf("Please enter the Number_of_Drawers\n\n"); scanf("%d", &drawers); \\i made this easy because i didnt want to stress about anything else. so you only have 3 options for drawers...3,4, and 5 if (drawers==3) { total=total+90.00; } else if (drawers==4) { total=total+120.00; } else if (drawers==5) { total=total+150.00; } else { printf("INVALID ENTRY\n"); } printf("Your current total is %d\n",total); \\subtotal from area and the total drawers printf("Please enter woodtype (m)ahogany add 150.00\n for (o)ak add 125.00\n there is no additional charge for (p)ine.\n\n"); scanf ("%c", &woodtype); if (woodtype=='m') { total=total+150.00; } else if (woodtype=='o') { total=total+125.00; } else if (woodtype=='p') { total=total; } else { printf("INVALID ENTRY\n"); } printf("Your total is %d",total); return 0; }



LinkBack URL
About LinkBacks



