Need help with C++

I desperately need help with the following:

"Suppose a cuboid has three sides length, depth and height. Write a C++ program that reads from keyboard these 3 sides in the form of integers, with proper input prompt/s, then display the volume of the cuboid, i.e. the product of these 3 sides. If these 3 sides are of equal length, then display the message "The cuboid is a cube.". If two of the 3 sides, but not all the three, are equal to each other, then display the message "The cuboid has a square face but is not a cube.". If none of the 3 sides are equal to one another, then display the message "The cuboid has no square faces."."

I have attempted it several times but all resulted in failure.
Any help would be greatly appreciated.
show your code and we will show where you went wrong.

We do not do your homework for you. Though we will provide feed back to what you did and help where we see needed.

this project doesn't seem too hard at all.

you will need 3 inputs, with 3 different variables
1
2
3
4
5
6
7
8
9
10
11
12
cin >> width;
cin >> height;
cin >> depth;

if(width == height || width == height || height == depth) 
{
//do some output
} 
else 
{
//print some answer
}
Last edited on
I've tried this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;

int main ()
{
	float l, d, h, volume;
	cout << "Enter length: ";
	cin >> l;
	cout << "Enter depth: ";
	cin >> d;
	cout << "Enter height: ";
	cin >> h;
	volume= l*d*h;
	cout <<"Volume= " << volume << endl;
	
	if(l == d || d == h || h == l)
	cout <<"cube";
	else if(l == d || h != d)
	cout <<"not cube but square face";
	else if(d == h || l != d)
	cout <<" not cube but square face";
	else if(l != d || d != h)
	cout <<" no square faces";
	else cout <<"invalid value entered";


The input prompts work fine and it displays the volume, but it always says it's a cube no matter what numbers I enter for length, depth and height.
I finally worked it out, but thank you for your help.

This seems to work for me:
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
#include <iostream>
using namespace std;

int main ()
{
	float l, d, h, volume;
	cout << "Enter length: ";
	cin >> l;
	cout << "Enter depth: ";
	cin >> d;
	cout << "Enter height: ";
	cin >> h;
	volume= l*d*h;
	cout <<"Volume= " << volume << endl;
	
	if(l == d && d == h)
	cout <<"cube";
	else if(l == d && h != d)
	cout <<"square face";
	else if(d == h && l != d)
	cout <<"square face";
        else if(l == h && d !=h)
	cout <<"square face";
	else if(l != d && d != h)
	cout <<" not cube";
	else cout <<"invalid";
Topic archived. No new replies allowed.