Guest User

Untitled

a guest
Oct 1st, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4.  
  5. class Rectangulo
  6. {
  7. private:
  8.     float base, altura;
  9. public:
  10.     void leer();
  11.    void comprobar();
  12.     void area();
  13.    void perimetro();
  14. };
  15.  
  16. void Rectangulo::leer()
  17. {
  18.     cout<<"Ingrese la base: ";cin>>base;
  19.    cout<<"\nIngrese la altura: ";cin>>altura;
  20. }
  21. void Rectangulo::comprobar()
  22. {
  23.     if(base>0 && altura>0 && base<20 && altura<20)
  24.    {
  25.       Rectangulo::area();
  26.     Rectangulo::perimetro();
  27.    }
  28.    else
  29.    {
  30.     clrscr();
  31.     cout<<"No se puede mostrar calculo.";
  32.    }
  33. }
  34. void Rectangulo::area()
  35. {
  36.     cout<<"\nEl area es: "<<base*altura;
  37. }
  38. void Rectangulo::perimetro()
  39. {
  40.     cout<<"\nEl perimetro es: "<<(2*base)+(2*altura);
  41. }
  42.  
  43. int main()
  44. {
  45.     Rectangulo r1;
  46.     r1.leer();
  47.    r1.comprobar();
  48.  
  49. getch();
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment