Advertisement
Guest User

Calculadora

a guest
Oct 13th, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. //strcpy()...
  4. using namespace std;
  5.  
  6. class calculadora{
  7. private:
  8. float x;
  9. float y;
  10. public:
  11. calculadora (float, float);
  12. float suma();
  13. float resta();
  14. float multiplicar();
  15. float dividir();
  16. void datos();
  17. };
  18.  
  19. calculadora::calculadora(float _x, float _y){
  20. x= _x;
  21. y= _y;
  22. }
  23. void calculadora::datos(){
  24. cout<<"Valor x : ";
  25. cin>>x;
  26. cout<<"Valor y : ";
  27. cin>>y;
  28. }
  29. float calculadora::suma(){
  30. return x+y;
  31. }
  32. float calculadora::resta(){
  33. return x-y;
  34. }
  35. float calculadora::multiplicar(){
  36. return x*y;
  37. }
  38. float calculadora::dividir(){
  39. return x/y;
  40. }
  41.  
  42. int main(){
  43. int A,B;
  44. calculadora a(A,B);
  45. a.datos();
  46.  
  47. cout<<" Suma : ";
  48. cout<<a.suma()<<endl;
  49. cout<<" Resta : ";
  50. cout<<a.resta()<<endl;
  51. cout<<" Producto : ";
  52. cout<<a.multiplicar()<<endl;
  53. cout<<" Dividir : ";
  54. cout<<a.dividir()<<endl;
  55.  
  56. getch();
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement