Beginner stumped..

This is a discussion on Beginner stumped.. within the C Programming forums, part of the General Programming Boards category; Program requirements: Code: * Your program should prompt the user to enter the length of the room to be painted. ...

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

    Beginner stumped..

    Program requirements:

    Code:
        * Your program should prompt the user to enter the length of the room to be painted.
        * Your program should prompt the user to enter the width of the room to be painted.
        * Your program should prompt the user to enter the height of the room to be painted.
        * Your program should prompt the user to enter the total square footage of windows in the room. After all, you wouldn't expect to paint the windows themselves.
        * Your program should calculate the number of gallons needed to paint the room. Assume that one gallon of paint will cover 200 square feet of wall.
        * Your program should print a message indicating how many gallons of paint will be needed to paint the room.
    We were given a program to write outside of class for extra. I am stuck though..

    This is what I have, not sure where to go though...

    Code:
    
    #include <stdio.h>
    	main()
    {	
    
    
    	Paint values = 1 gallon of paint covers 200 square/feet.
    
    	        
    	printf("input room dimensions\n");
    	printf("length? ");
    	scanf("%f", &length);
    	printf("width? ");
    	scanf("%f", &width);
    	printf("height ?");
    	scanf("%f", &height");
    
    	printf("input total square/feet of windows in room\n");
    	printf("sqaure_feet? ");
    	scanf("%f", &square_feet);
    
    	wall_area = 2*height*(length+width)-(window_area + door_area);
    	gallons = (wall_area/window_area) + 0.999 ;
    	printf("number of gallons needed to paint room = %d\n", gallons);
    
    }
    Any help? This is my first programming class to take, so it is a bit foreign to me..

  2. #2
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198

    Smile

    Quote Originally Posted by kiorei View Post
    Program requirements:

    Code:
        * Your program should prompt the user to enter the length of the room to be painted.
        * Your program should prompt the user to enter the width of the room to be painted.
        * Your program should prompt the user to enter the height of the room to be painted.
        * Your program should prompt the user to enter the total square footage of windows in the room. After all, you wouldn't expect to paint the windows themselves.
        * Your program should calculate the number of gallons needed to paint the room. Assume that one gallon of paint will cover 200 square feet of wall.
        * Your program should print a message indicating how many gallons of paint will be needed to paint the room.
    We were given a program to write outside of class for extra. I am stuck though..

    This is what I have, not sure where to go though...

    Code:
    
    #include <stdio.h>
    	main()
    {	
    
    
    	Paint values = 1 gallon of paint covers 200 square/feet.
    
    	        
    	printf("input room dimensions\n");
    	printf("length? ");
    	scanf("%f", &length);
    	printf("width? ");
    	scanf("%f", &width);
    	printf("height ?");
    	scanf("%f", &height");
    
    	printf("input total square/feet of windows in room\n");
    	printf("sqaure_feet? ");
    	scanf("%f", &square_feet);
    
    	wall_area = 2*height*(length+width)-(window_area + door_area);
    	gallons = (wall_area/window_area) + 0.999 ;
    	printf("number of gallons needed to paint room = %d\n", gallons);
    
    }
    Any help? This is my first programming class to take, so it is a bit foreign to me..
    First make your main return int:

    Code:
    int main()
    {
           code here
    
         return 0;
    
    }

    Second, you are using float variables (length, height, etc.) without any
    declarations. I'm assuming you know how to do that.

    Edit:
    Code:
    Paint values = 1 gallon of paint covers 200 square/feet.
    <--- what is that supposed to do?

    Edit#2:


    :Paint values = 1 gallon of paint covers 200 square/feet.
    With the statement above, I've come to the conclusion that you probably don't know how to declare variables yet. Check out the link below.


    http://en.wikipedia.org/wiki/C_varia...d_declarations
    Last edited by Char*Pntr; 09-22-2010 at 03:49 PM. Reason: additional info...

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    2
    Ah. you are right. I am trying to follow along with the book Through C to C++: a complete programming course with what I am doing. Doesn't look like that is helping too much it seems.

    Thanks for the link and for replying.

    Edit.

    Ok, I think this is better. It looks closer to what the book is using..

    Code:
    #include <stdio.h>
    
    	void main(void)
    {
    	const	float	paint_cover = 200.0;
    
    	
    	float	length, width, height;
    	float	wall_area;
    	int	gallons;
    
    
    	printf("input room dimension\n");
    	printf("length? ");
    	scanf("%f", &length);
    	printf("width? ");
    	scanf("%f", &width);
    	printf("height? ");
    	scanf("%f", &height);
    
    	wall_area = 2*height*(length + width)- (window_area)
    	gallons = (wall_area / paint_cover) + 0.999;
    
    	printf("number of gallons needed to paint room = %d\n", gallons);
    
    }
    The question I have is how do I declare window_area a unknown, as it is left up to the user...

    or is this completely wrong...
    Last edited by kiorei; 09-22-2010 at 04:37 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 12:48 PM
  2. What are some good beginner programs I shouold make?
    By oobootsy1 in forum C# Programming
    Replies: 6
    Last Post: 08-09-2005, 03:02 PM
  3. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM
  4. help with stl search/find, or something else- stumped!
    By Terranc in forum C++ Programming
    Replies: 3
    Last Post: 12-21-2002, 04:11 PM

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