Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication4.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- const float pi = 3.14159;
- float side;
- cout << "Geometric Formulas by John Arno\n" << endl;
- cout << "enter a number \n" << endl;
- cin >> side;
- cout << "\n";
- cout << "you entered \t " << side << endl << endl;
- // area of the square
- int square = side * side;
- cout << "the area of the square is \t" << square << " sq. m" << endl;
- // area of the circle
- float circle = (side * side) * pi;
- cout << "the area of the circle is \t" << circle << " sq. m" << endl;
- // difference of the areas
- double diff = circle - square;
- cout << "the difference of the areas is \t" << diff << " sq. m" << endl;
- cout << '\n';
- // rounding up and down
- double up = ceil(diff);
- cout << "the difference rounded up is \t" << up << " sq. m" << endl;
- cout << "\t the volume of that cube is " << (up * up * up) << " cu. m" << endl;
- double down = floor(diff);
- cout << "the difference rounded down is \t" << down << endl;
- cout << "\t the volume of that cube is \t" << (down * down * down) << " cu. m" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement