Advertisement
Guest User

Code

a guest
Jan 28th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdlib.h>
  3. #include <string>
  4. #include <iostream>
  5. #include <cmath>
  6. using namespace std;
  7.  
  8. float Height, Width, Area,Radius;
  9. const float pi = 3.14159265359;
  10. char object,Object;
  11. void area_triangle() {
  12. system("CLS");
  13. cout<<"What is the height of the triangle?"<<endl;
  14. cin>>Height;
  15. cout<<"What is the width of the triangle?"<<endl;
  16. cin>>Width;
  17. system("CLS");
  18. Area = 0.5 * Height * Width;
  19. cout<<"The Area of the triangle is : "<<Area<<endl;
  20. system("pause");
  21. system("CLS");
  22. }
  23.  
  24. void area_circul(){
  25. system("CLS");
  26. cout<<"What is the Radius of the Circul?"<<endl;
  27. cin>>Radius;
  28. system("CLS");
  29. Area = pi * Radius * Radius;
  30. cout<<"The Area of the Circul is : "<<Area<<endl;
  31. system("pause");
  32. system("CLS");
  33. }
  34.  
  35. void area_rectangular () {
  36. system("CLS");
  37. cout<<"What is the height of the Rectangular?"<<endl;
  38. cin>>Height;
  39. cout<<"What is the width of the Rectangular?"<<endl;
  40. cin>>Width;
  41. system("CLS");
  42. Area = Height * Width;
  43. cout<<"The Area of the Rectangular is : "<<Area<<endl;
  44. system("pause");
  45. system("CLS");
  46. }
  47.  
  48. void main () {
  49. cout<<"What is the object you want ot calculate the area of?"<<endl;
  50. cout<<"use 'C' for Circul, 'R' for rectangular, and 'T' for triangle"<<endl;
  51. cin>>object;
  52. Object = toupper(object);
  53. switch (Object){
  54. case 'C':
  55. area_circul();
  56. main();
  57. break;
  58. case 'T':
  59. area_triangle();
  60. main();
  61. break;
  62. case 'R':
  63. area_rectangular();
  64. main();
  65. break;
  66. default:
  67. system("CLS");
  68. cout<<"you haven't choose the right letter, please try again"<<endl<<endl;
  69. main();
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement