Write a C++ program that allows the user to enter the % of the moon's face that appears illuminated, and that outputs the surface area of that portion of the moon.
The moon's radius is 1738.3 km so for 100% of the moon illuminated (full moon), is would be:
S = 2 x 1738.3 x 3.14159 = 18985818.672 square kilometres.
I created a program but I can't get it to go to the exact decimal (shows 18985820.000), and I can only get the 100% calculation to work. Help!?
cout << "Please enter the % of the moon's face that appears illuminated: ";
cin >> rate;
cout << "The surface area based on your percentage is: ";
cout << fixed << setprecision(3) << 2 * pow(radius,2) * PI * (rate/100) << " square kilometres." << endl;