Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdlib.h>
- #include <string>
- #include <iostream>
- #include <cmath>
- using namespace std;
- float Height, Width, Area,Radius;
- const float pi = 3.14159265359;
- char object,Object;
- void area_triangle() {
- system("CLS");
- cout<<"What is the height of the triangle?"<<endl;
- cin>>Height;
- cout<<"What is the width of the triangle?"<<endl;
- cin>>Width;
- system("CLS");
- Area = 0.5 * Height * Width;
- cout<<"The Area of the triangle is : "<<Area<<endl;
- system("pause");
- system("CLS");
- }
- void area_circul(){
- system("CLS");
- cout<<"What is the Radius of the Circul?"<<endl;
- cin>>Radius;
- system("CLS");
- Area = pi * Radius * Radius;
- cout<<"The Area of the Circul is : "<<Area<<endl;
- system("pause");
- system("CLS");
- }
- void area_rectangular () {
- system("CLS");
- cout<<"What is the height of the Rectangular?"<<endl;
- cin>>Height;
- cout<<"What is the width of the Rectangular?"<<endl;
- cin>>Width;
- system("CLS");
- Area = Height * Width;
- cout<<"The Area of the Rectangular is : "<<Area<<endl;
- system("pause");
- system("CLS");
- }
- void main () {
- cout<<"What is the object you want ot calculate the area of?"<<endl;
- cout<<"use 'C' for Circul, 'R' for rectangular, and 'T' for triangle"<<endl;
- cin>>object;
- Object = toupper(object);
- switch (Object){
- case 'C':
- area_circul();
- main();
- break;
- case 'T':
- area_triangle();
- main();
- break;
- case 'R':
- area_rectangular();
- main();
- break;
- default:
- system("CLS");
- cout<<"you haven't choose the right letter, please try again"<<endl<<endl;
- main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement