I have recently started learning C++ and I'm having some trouble with the following problem:

"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."."

It seemed easy to me when I first read it but every attempt I've made has resulted in failure, any help would be greatly appreciated.

Edited 4 Years Ago by Sloppos21: typo

A great place to start is the "Read Me: Read This Before Posting A Question" item at the top of the forum listing. Since we're not mind-readers, and can't see your screen from this far away, we don't know what you've attempted, nor what specific failures resulted. Can you prompt for user input? Can you accept the input from the user? Can you verify that you've accepted the input? From there, computing the volume and doing some simple comparison testing shouldn't be too hard.

Sorry, I guess that was a bit vague.
I can pretty much get through the following:

#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;

but once I get to the comparison testing part, I'm not entirely sure as to what I type in.
Also, if I've made any mistakes in the code that I've got so far, please let me know.

I finally worked it out.

This seems to work for me:

    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";
This question has already been answered. Start a new discussion instead.