Thread: Please help asap!!! :(

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    4

    Unhappy Please help asap!!! :(

    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;
    
    }

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472

    wrong order

    Code:
    printf("Please enter width\n\n");
    scanf("%d", &width);
    printf("Thank you!\n\nPlease enter length\n\n");
    area=width*length;
    
    scanf("%d", &length);
    well one thing wrong is you are calculating area before you get input for length, move the scanf length line above the area calc line

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    4
    thnkx. I FINALLY got it....feel incredibly dumb but thats what sleep deprivation does i guess.
    in my variables i declaried baseprice as 200.00 and total as 0....long story short...cut out base price. fixed area and had printf("Your current total is %.2f\n",total); as a reminder to end user..got an A in CIS 126! thanks rogster

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    You're telling me it actually works, while you use "\\" to start a comment?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help with C Programming ASAP
    By yabs in forum C Programming
    Replies: 2
    Last Post: 12-07-2009, 10:32 PM
  2. need help ASAP ,
    By Haytham in forum C Programming
    Replies: 3
    Last Post: 05-14-2007, 10:21 AM
  3. Need Help ASAP....
    By Maxwell in forum C++ Programming
    Replies: 16
    Last Post: 09-14-2005, 06:56 PM
  4. Count_nums (need help ASAP!)
    By legacye in forum C Programming
    Replies: 6
    Last Post: 11-22-2003, 06:32 PM
  5. Help Needed Asap With Searching An Array!
    By HelpMe++ in forum C++ Programming
    Replies: 5
    Last Post: 05-23-2003, 04:44 AM