Help: Program to calc space and money for apartments

This is a discussion on Help: Program to calc space and money for apartments within the C Programming forums, part of the General Programming Boards category; I have this assignment that I need some help on I am posting the problem then what I have also ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    2

    Help: Program to calc space and money for apartments

    I have this assignment that I need some help on I am posting the problem then what I have also I think that it should be a loop but am not sure. Any help is appreciated my instructor will not help me or he tells me I am right and then when he grades it he says it is wrong. Thanks.
    MightyM991@aol.com
    The Acme Real Estate Company is planning an apartment complex. The company figures that during the first year, its income will be $450 per month from each studio apartment, $550 per month from each one-bedroom apartment, and $700 per month from each two-bedroom apartment. Each studio apartment will be 200 square feet in size; each one-bedroom apartment will be 300 square feet in size, and each two-bedroom apartment will be 450 square feet in size. The building cost is $75 per square foot. To aid in planning, the company wants a program that will allow it to input the number of studios, one-bedroom, and two-bedroom apartments and will calculate the total size of the building needed to house the apartments, the total building cost, and the expected income for the first year and output those results in report form. Write this program and structure it so that Acme can enter as many sets of data as desired at one time. A sample run follows.
    ACME REAL ESTATE PLANING PROGRAM
    How many studio apartments? 5
    How many one-bedroom apartments? 12
    How many two-bedroom apartments? 10
    Report for 5 studio apartments
    12 one-bedroom apartments
    10 two-bedroom apartments
    Space Costs Income
    Studios: 1000 75000 27000
    One-Bedrooms: 3600 270000 79200
    Two-Bedrooms: 4500 337500 84000
    ------------------------------ --------- ---------
    Totals Space: 9100 Cost: 682500 190200
    Do you want to enter another set of data (y/n)? n
    Thank you

    Here is what I have and I don't know what else to do, I am not sure where I need to go from here. I am confused. I am using MS visual studio ver 6.0.

    #include<stdio.h>

    /* Function Prototypes */

    int main(void)
    {

    int intvar;

    printf("ACME REAL ESTATE PLANNING PROGRAM");
    printf("---------------------------------");

    /* Input the number of apartments */
    printf("How many studio apartments?\n");
    scanf("%d", intvar);

    printf("How many one-bedroom apartments?\n");
    scanf("%d", intvar);

    printf("How many two-bedroom apartments?\n");
    scanf("%d", intvar);

    printf("Report for %d studio apartments\n", intvar);
    printf("%d one-bedroom apartments\n", intvar);
    printf("%d two-bedroom apartments\n", intvar);

    printf(" Space Costs Income\n");
    printf(" Studios:
    printf("One-Bedrooms:
    printf("Two-Bedrooms:
    printf("-------------
    printf("Totals Space: Cost:
    printf("Do you want to enter another set of data (y/n)?\n");

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    To make your code a lot easier to read, please wrap it in [code] [/code] tags.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    140
    First, you're asking 3 questions so you need 3 variables to store the results. something like
    Code:
    int num_of_studio = 0;
    int num_of_one_bedroom = 0;
    int num_of_two_bedroom = 0;
    scanf expects the address of the variable you're reading into so:
    Code:
    printf("How many studio apartments?\n");
    scanf("%d", &num_of_studio);
    your calculations should be simple and you can do them within printf (you could also store the calculation in a separate variable, might be easier when printing totals) example:
    Code:
    printf(" Studios: %d %d %d\n", num_of_studio * 200, num_of_studio * 200 * 75, num_of_studio * 12 * 450);
    Also, it might be a nice idea to store your constants in variables or #define 's with meaninful names like
    Code:
    #define studio_sq_feet 200 
    #define studio_per_month 450
    #define building_cost 75
    finally to ask the questions multple times you'll need an additional varaible and loop
    Code:
    char again = 'n';
    
    do
    {
      .... /* all your code to get and print the data */
      printf("Do you want to enter another set of data (y/n)?\n");
      scanf("%c", &again);
    }while(again == 'y');
    Last edited by spydoor; 09-21-2005 at 11:52 AM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,848
    > MightyM991@aol.com
    I generally ignore people who just dump homework on a board along with an email address. To me it means you've spammed your post to a whole host of boards (too many to remember to revisit), but since all you care about is some schmuck posting you the answer, you don't care.
    FYI - you can set your preferences to email you when there are replies to your threads.

    But since you actually made an attempt, let me help you along

    printf("How many studio apartments?\n");
    scanf("%d", intvar);

    printf("How many one-bedroom apartments?\n");
    scanf("%d", intvar);

    1. Scanf needs a pointer, so
    scanf("%d", &intvar);

    2. You need more than one variable, say
    int numStudios, num1BedApts, num2BedApts;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    2
    Salem I don't want just some smuck giving me the answer all I asked for was some direction and not the answer. Also I did not send it to tons of different boards this is the only one I even know about and I did set it to e-mail me when there is a response. I just put my e-mail on it because I am used to putting it on everything. Thanks for your help but please don't judge me until you know my true intentions it won't help me for someone to do the work for me if I don't understand what is going on. I just wanted help because my instructor is an idiot and won't help at all and when he does he says that is right and then when he grades it he says it is wrong. So thanks for the help but please don't think I am just wanting someone to do it for me all I want is help to understand this and to understand where I am going wrong. Thanks to all that responded.
    MightyM991@aol.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [NEED HELP] I just can't solve this program problem!
    By frodonet in forum C Programming
    Replies: 7
    Last Post: 09-23-2007, 03:44 PM
  2. someone who is good at finding and fixing bugs?
    By elfjuice in forum C++ Programming
    Replies: 8
    Last Post: 06-07-2002, 04:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21