Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 1: Sphere program 20% This program will calculate the surface area and volu

ID: 1715697 • Letter: P

Question

Part 1: Sphere program                                                                               20%

This program will calculate the surface area and volume of a sphere given the radius. The radius will be input from the keyboard and validated (i.e., ensure that the radius is >= 0), and the surface area and volume will be calculated, with 2-decimal places accuracy, and outputted to the screen.

Evaluation

This program is worth 20% of the grade. The evaluation is as follows:

Input Statements                                                                                                                                      

Calculation Statements                                                                                                                            

Output Statements                                                                                                                                    

Comments                                                                                                                                                

Algorithm

Use a constant for PI = 3.14

Input radius of the sphere.

Compute and print out the surface area of the sphere – Surface = 4 * PI * r2.

Compute and print out the volume of the sphere - Volume = (4/3)*PI*r3.

Exit (return).

Code

Create a new project called Sphere and add to it a C source file named sphere.c.

Submission

Submit the C code for sphere.c

Explanation / Answer

#include<iostream.h>

#include<iomanip.h>

#include<conio.h> // including header files

void main()

{

float r, area, cir; //declaration of values or radius, area, circumference

clrscr(); //clearing the screen

cout<<"Enter radius:"; //asking user to input value of radius

cin>>r; // value of radius taken in variable r

area = 4.0 * 3.14 * r *r; // formula for area of sphere

cir = (4.0/3.0) * 3.14 * r * r *r; // formula for circumference of sphere

cout<<"Areais:"<<setprecision(2)<< area<<endl; //printing the result of area and putting to two decimal places condition

cout<<"Circumferenceis:"<<setprecision(2)<<cir;//printing the result of circumference and putting to two decimal places condition

getch(); // holding the result on screen

}