/* CalcArea2.cpp CIS 150 Dave Klick 2017-01-18 Basic numeric C++ input and output with calculations and output formatting. This program calculates the area of a circle given the diameter. */ #include // for: cin, cout, endl, fixed, showpoint #include // for: setprecision using namespace std; int main() { // Declare variables double diameter; double radius; double area; const double PI = 3.1415926; // Get diameter from user cout << "Enter the diameter: "; cin >> diameter; // Calculate area radius = diameter / 2.0; area = PI * radius * radius; // Display result with one digit after the decimal point cout << "The area of the circle is " << fixed << showpoint << setprecision(1) << area << '\n'; cout << "Press to continue... "; cin.get(); return 0; }