Hi,
Did you know that you can compile & run your code right here by using the gear icon on the right of the code you posted?
You appear to have multiple problems going on here, I think you need to completely review your knowledge right from the beginning. Have a look at the tutorial at the top left of this page.
One can't have the same variable name with different types.
Golden Rule Always initialise variables to some value,
preferably at the same time as declaration. You have multiple places which produce garbage (garbage in, garbage out)
Code is executed in the order you have it in your file, the order you have things is messed up.
It doesn't make sense to do a calculation with garbage, then ask for input for that variable, like you do on lines 21 & 22 for example. Get input with
cin
for each variable you need, then do the calculation.
The
pi
variable is neither declared nor initialised.
The
^
operator is not exponentiation, rather it is binary XOR - which is entirely different. If you want to square something just multiply as in
radius * radius
Line 27 - the comma is not doing what you think, rather it should look like this:
27 28 29
|
if ( (rectangle <= 0) || (circle <= 0) || (sphere <= 0) || (box <= 0) ) {
// your code here
}
|
An alternative to the
||
or operator is simply
or
:
27 28 29
|
if ( (rectangle <= 0) or (circle <= 0) or (sphere <= 0) or (box <= 0) ) {
// your code here
}
|
Line 29 doesn't make sense at all.
Lines 31 & 32
cout
strings must be separated by
<<
operators , or just output 1 string literal:
cout << "The requested shape is not recognized" << "the system. Thank you\n" << endl;
or this:
1 2
|
cout << "The requested shape is not recognized";
cout << " by the system. Thank you\n";
|
or this:
cout << "The requested shape is not recognized by the system. Thank you\n";
As I said earlier, you need to review almost every aspect of your code, read up on how to do things properly - don't just do it how you might imagine it to be.
Good Luck :+)