Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. // ConsoleApplication4.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <cmath>
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. const float pi = 3.14159;
  12. float side;
  13.  
  14. cout << "Geometric Formulas by John Arno\n" << endl;
  15.  
  16. cout << "enter a number \n" << endl;
  17. cin >> side;
  18. cout << "\n";
  19. cout << "you entered \t " << side << endl << endl;
  20. // area of the square
  21. int square = side * side;
  22.  
  23. cout << "the area of the square is \t" << square << " sq. m" << endl;
  24.  
  25. // area of the circle
  26. float circle = (side * side) * pi;
  27. cout << "the area of the circle is \t" << circle << " sq. m" << endl;
  28.  
  29. // difference of the areas
  30. double diff = circle - square;
  31. cout << "the difference of the areas is \t" << diff << " sq. m" << endl;
  32. cout << '\n';
  33.  
  34. // rounding up and down
  35. double up = ceil(diff);
  36. cout << "the difference rounded up is \t" << up << " sq. m" << endl;
  37.  
  38. cout << "\t the volume of that cube is " << (up * up * up) << " cu. m" << endl;
  39.  
  40. double down = floor(diff);
  41. cout << "the difference rounded down is \t" << down << endl;
  42.  
  43. cout << "\t the volume of that cube is \t" << (down * down * down) << " cu. m" << endl;
  44.  
  45.  
  46.  
  47. system("pause");
  48.  
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement