#include<iostream>
#define PI 3.14
using namespace std;
int main(){
double r;
cout<<"Enter radius of sphere";
cin>>r;
double sa,vol;
sa=4*PI*r*r;
vol=(1.33)*PI*r*r*r;
cout<<"Surface area of sphere is "<<sa<<endl;
cout<<"Volume of sphere is "<<vol<<endl;
}
if you like the answer please provide a thumbs up.
Need in C++ Assignment #1: Write a program to ask the user for a sphere radius...
Please help me to write a program in C++ with comments and to keep it simple as possible. Thank you! Here is my program I have done before and that need to be change: #include <iostream> #include <iomanip> using namespace std; // function prototype – returning one value double cylvol(double, double); // Note: two data types inside brackets double surfarea(double, double); // Note: two data types inside brackets int main() { double r, l, V, S; cout << setprecision(2) <<...
Write a C++ program to compute the total volume of N cones, where N is a number entered by the user. Repeat the request for N until the user enters a positive number. For each cone, ask for the radius and height, compute the volume, and add that volume to the total. Each time you ask the user to enter either the height or the radius, if the user does not enter a positive number, display an error message and...
Problem: Write a short C++ program that gets the side of a cube and the radius of a sphere from the keyboard and writes to a file the surfaces of these shapes. ------------------------------------------------------------------------------------------------------------------------ Your task: implement in C++ the algorithm solution shown below. ------------------------------------------------------------------------------------------------------------------------ Part A (79 points) Algorithm solution (in pseudocode): To accomplish this task, your program will have to take the following steps: 1. Declare a variable named outFile that represents an output stream. 2. Declare a...
Can someone help me with this coding question. I cannot get this to run properly. Write a program that defines the named constant PI, const double PI = 3.14159;, which stores the value of π. The program should use PI and the functions listed in Table 6-1 to accomplish the following: Output the value of √π . Prompt the user to input the value of a double variable r, which stores the radius of a sphere. The program then outputs...
Problem 3 (5 points) Write a program that prompts the user for the radius of a sphere. Your program should then compute values for the area, and volume of the sphere. Your program should then output the results for the sphere area, and volume. Enter the radius of the sphere as a real number? 10.5 The area of a sphere with radius 10.5 is 1385.44 The volume of a sphere with radius 10.5 is 4849.05
Geometric calclator use python to do this program. Write a program that displays the following menu: 1. Calculate the area of circle 2. calculate the area of rectangle 3. calculate the area of triangle 4. Quit Enter your choice (1-4). if the user enters 1, your program should ask for the radius of the circle and then display its area. Use the formula to calculate the circle's area: Area = pi*r^2 Use 3.14149 for Pi and the radius of the...
Write a program to calculate the volume and surface area of a sphere from it radius given as input. Here are some formulas that might be useful: V = 4/3πr3 A = 4 πr2
using Java The formula to compute the volume of a sphere is: volume = ( 4 3 ) π r 3 where r is the radius of the sphere and π is 3.14159. Assume a variable radius has already been declared (type double) and initialized with the value of the radius of a sphere. Write java statements to do the following: Declare a constant PI and initialize it to 3.14159 Declare a variable volume of type double Calculate the volume...
PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ CODE Consider the following program in which the statements are in the incorrect order. Rearrange the statements in the following order so that the program prompts the user to input: The height of the base of a cylinder The radius of the base of a cylinder The program then outputs (in order): The volume of the cylinder. The surface area of the cylinder Format the output to two decimal...
Please do this in C language. Thank you 1. Write the following functions that compute the volume and surface of a sphere with radius r; a cylinder with circular base with radius r and height h; and a cone with circular base with radius r and height h. Place these functions in appropriate class. Define n (PI) as a constant variable equals to 3.14 then use it in the functions. float sphereVolume(float r) float sphereSurface(float r) float cylinderVolume(float r, float...