Need help voLume of room

Hi need some help with the following task:

Write a program that wil compute the volume of a room. User inputs are the height,width and length of each room. You have to declare 3 functions.

a)one for input
b)one to do the calculation,and
c)one for output

The input function has to input the height,width and length into the variables theHeight,theLength,theWidth. all 3 are of type int. As the values of them wil change in this function reference parameters need to be used.

The calculation function wil receive three parameters the represent the height, width and length do calculation and return the volume of the room.As the parameters are not changed in the function, they should be value parameters. The function should return an int value which represents the volume.

Output function has to display the height, width and length entered by the user as well as the volume. you also have to indicate the size of the room as small,medium,large. If the volume is less than 100 the volume is small,between 100 and 500 the size is medium and greater than 500 the size is large.

For example:
The volume of a room with height 3, width 4 and length 5 is 60.
Size: Small

The main function includes a for loop that allows the user to repeat the calculation of the volume for new input values five times.

If you could help me i'll appriate it.
Last edited on
closed account (G854izwU)
Here you go even though I'm not sure what you would use it for.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//This code was made completely by -TheNewKid-  Please do not take credit for this code.

#include <iostream>

using namespace std;
int main ()
{
    int height = 0;
    int length = 0;
    int width = 0;
    int volume = 0;

    cout << "Welcome to the room volume calculator created by -TheNewKid-!" << endl << endl;
    cout << "Please enter the height of your room: ";
    cin >> height;
    cout << endl << "Please enter the width of your room: ";
    cin >> width;
    cout << endl << "Please enter the length of your room: ";
    cin >> length;
    cout << endl << "Thank you for your input." << endl;

    volume = height * length * width;

    cout << "The volume of your room with width " << width << ", height " << height <<", and length " << length << " is " << volume << "." << endl;

    if (volume < 100) {
        cout << "Size: small" << endl;
    }
    else if (volume > 100 && volume < 500) {
        cout << "Size: medium" << endl;
    }
    else {
        cout << "Size: large" << endl;
    }

    cout << endl << endl << "Thank you for using -TheNewKids- room volume calculator.";
    cout << endl << endl << "---end of program---" << endl << endl;



    return 0;
}
Thanks you for your time:)!!
closed account (G854izwU)
No problem.
Can't u use a for loop for example:

int main( )
{
int theHeight;
int theWidth;
int thelength;
int theVolume;

for (int i = 0; i < 5; i++)
{
getData(theHeight, theWidth,theLength);
displayOutput(theHeight, theWidth, theLength, theVolume);

}
return 0;

}
Anyone??
closed account (G854izwU)
What would be the purpose?
I would just like to see how the code could be replaced with a for loop:)
anyone?
If you want something that loops 5 times, you can do it like this. You've got all the information you need already to write the functions getData and displayOutput

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main( )
{
  int theHeight;
  int theWidth;
  int thelength;
  int theVolume;

  for (int i = 0; i < 5; i++)
  {
    getData(theHeight, theWidth,theLength);
    displayOutput(theHeight, theWidth, theLength);
  }
return 0;
}
Last edited on
That is the part that gives me head pain.... Im strugeling with writing the functions of getdata and displayOutput sorry i know i'm still learning^^
plz need this program urgent
Well the whole purpose of the assignment is for you to struggling with writing those functions and write them yourself.
I have been busy for a week now and i came back to this question so plz just help me out here
Anyone?
Write your own code!

This is what happens when you beg for code and someone gives you an answer. You haven't got a clue how to change it to suit your needs.
or u could just explain to me?
Everything you need is already in this post.

Someone posted the code above, all you need to do is put it into functions. If you don't understand functions, then: http://www.cplusplus.com/doc/tutorial/functions/
Topic archived. No new replies allowed.