All pastes #228615 Raw Edit

Anonymous

public cpp v1 · immutable
#228615 ·published 2006-10-30 04:43 UTC
rendered paste body
#include <iostream>#include <iomanip>#include <cctype>#include <string>using namespace std;int area(int l, int w);double area(double b, double h);double perimeter(double half, int b, int h);int perimeter(int a, int bc, int c);int main(){	int length, width;	double half = .5, base, height;	int side1, side2, side3;	char input, input2;	cout << "What do you want to do?\n";	cout << "Calculate [a]rea or [p]erimeter?";	cin >> input;	switch (input)	{	case 'a':		cout << "Calculate area of [r]ectangle or [t]riangle?";		cin >> input2;				switch (input2)		{			case 'r':				{				cout << "Enter the length and width of the rectangle: ";				cin >> length >> width;				cout << "Area of the rectangle: " << area(length, width) << endl;				}			case 't':				{				cout << "Enter the base and height of the triangle: ";				cin >> base >> height;				cout << area(base, height);				}		}	case 'p':		cout << "Calculate perimeter of [r]ectangle or [t]riangle?";		cin >> input2;				switch (input2)		{			case 'r':				{				cout << "Enter the length and width of the rectangle: ";				cin >> length >> width;				cout << perimeter(half, length, width);				}			case 't':				{				cout << "Enter the length of all three sides of the triangle: ";				cin >> side1 >> side2 >> side3;				cout << perimeter(side1, side2, side3);				}		}	}    return 0;}int area(int l, int w){	return( l * w );}double area(double b, double h){	return( .5 *(b * h));}double perimeter(double h, int l, int w){	return( h * ( l+w ));}int perimeter(int a, int b, int c){	return( a + b + c);}