Hey,
Im trying to create a program that will ask the user to input a set of numbers (measurments =length, width, height; using formula for surface area) for a room, and then will be prompted if any other room measurments are to be calculated, at which point if they answer yes, the program will run through again.
At the end of it, (when they answer no at the prompt to measure any other rooms) the program will caluclate the total amount of area for all the rooms put together (adding surface area for one room, to another, etc.).
Now, Ive been racking my brain over this for the past few hours, and I feel like Im just going in a circle.
My main question is, how do I get the computer to recognize one length (ex length1) and allocate it for future use, and recognize another length (ex length2)
without the previous variable being over-allocated?
I was thinking to create local variables within a function, but Im still left with this problem ultimately as even if I do that, ill still be left with variables of the same name that somehow have to be added to one another.Would pointers be an option?
Its simply because of the dependancy on whether or not the person chooses to do multiple roooms that's grating on me. I cant see a clear way to foresee a way that can save variables, without overwriting variables of the same name, in the process.
Ex. If total_surface_a rea for my first loop of measurements resulted in 550 m,
and the next loop (because the user wanted another room to be calculated), total_surface_a rea measurements resulted in 600 m...
How am I supposed to add 550 and 600 if they're allocated within the same space, while still making sure if a person wants 1 room or 10 rooms measured, ultimately all those areas can be caluclated in a total?
Im not looking for someone to give me the straight out answer, but, if I could even be pointed in the right direction or given a suggestion it would help me out.
Thanks a lot
Im trying to create a program that will ask the user to input a set of numbers (measurments =length, width, height; using formula for surface area) for a room, and then will be prompted if any other room measurments are to be calculated, at which point if they answer yes, the program will run through again.
At the end of it, (when they answer no at the prompt to measure any other rooms) the program will caluclate the total amount of area for all the rooms put together (adding surface area for one room, to another, etc.).
Now, Ive been racking my brain over this for the past few hours, and I feel like Im just going in a circle.
My main question is, how do I get the computer to recognize one length (ex length1) and allocate it for future use, and recognize another length (ex length2)
without the previous variable being over-allocated?
I was thinking to create local variables within a function, but Im still left with this problem ultimately as even if I do that, ill still be left with variables of the same name that somehow have to be added to one another.Would pointers be an option?
Its simply because of the dependancy on whether or not the person chooses to do multiple roooms that's grating on me. I cant see a clear way to foresee a way that can save variables, without overwriting variables of the same name, in the process.
Ex. If total_surface_a rea for my first loop of measurements resulted in 550 m,
and the next loop (because the user wanted another room to be calculated), total_surface_a rea measurements resulted in 600 m...
How am I supposed to add 550 and 600 if they're allocated within the same space, while still making sure if a person wants 1 room or 10 rooms measured, ultimately all those areas can be caluclated in a total?
Im not looking for someone to give me the straight out answer, but, if I could even be pointed in the right direction or given a suggestion it would help me out.
Thanks a lot
Comment