Assuming the homework isn't due yet ;-)
Here's most of the shapes listed in the syllabus, I'll let you figure out the rest yourself.
Code:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#include <iostream>
using namespace std;
int main()
{
float length;
float width;
float height;
float pi;
float volume;
float area;
pi = 3.1416;
cout << "The length of the shape is: ";
cin >> length;
cout << "The width of the shape is: ";
cin >> width;
cout << "The height of the shape is: ";
cin >> height;
if (height == 0 && length > 0 && width > 0)
{
cout << "The area of the rectangle is: ";
cout << length * width;
}
else if (height > 0 && length > 0 && width > 0){
cout << "The volume of the rectangular prism is: ";
cout << length * width * height;
}
else if (width > 0 && height == 0 && length == 0){
cout << "The area of the circle is: ";
cout << (width / 2) * (width / 2) * pi;
}
else if (width > 0 && height > 0 && length == 0){
cout << "The volume of the cylinder is: ";
cout << (width / 2) * (width / 2) * pi * height;
}
system("pause");
}
Did that with two days knowledge of C++...maybe you should pay attention in class? Haha