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:
import java.util.Scanner;
public class VolumeOfSphere {
public static void main(String args[]) {
final double PI = 3.14159; // declaring and initializing a CONSTANT using FINAL keyword
double volume; // declaring variable VOLUME of type double
double radius = 3.5; // declaring and initializing radius
volume = (4.0 / 3.0) * PI * (radius * radius * radius); // volume of sphere = 4/3 * PI * r^3
System.out.println("Volume Of Sphere is:" + volume); // Displaying the volume of sphere in the console
}
}
Screenshot of the code's output:
PLEASE UPVOTE!!
using Java The formula to compute the volume of a sphere is: volume = ( 4...
This is a C++ statement, when it comes to Algebra, this is very difficult for me to solve this, please help me solve this problem with step-by step solutions Question 27 10 pts (SHORT ANSWER) Write C++ statements to do the following (number your answers): 1. Declare a constant PI and initialize it with 3.1415 2. Declare a variable volume of type double 3. Calculate the volume of the cone and store it in the variable volume . Given the...
python programming Canvas → XCO Question 28 10 pts (SHORT ANSWER) Write Python statements to do the following (number your answers); 1. Create a constant PI and assign it 3.1415 2. Calculate the volume of the cone and store it in the variable volume . Given the formula to compute the volume of a cone is: II-> (5) • Assume: the variables r and h are already assigned with values 3. Display the computed volume on the console as follows...
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...
the volume of a sphere is given by v The volume of a sphere is given by V = (4/3)pi r^3, where r is the radius. Compute the volume of a sphere with a radius of 925 pm. State your answer in units of m^3.
Need in C++ Assignment #1: Write a program to ask the user for a sphere radius r as a double. Then compute and display the sphere surface area using S-4*PI'r*r as double. Then compute and display the sphere volume using V-(1.33)*PIr'r*r as double. Use: const double PI-3.14;
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...
Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Write and document your program per class coding conventions. Add an instance variable double radius. Generate...
write your code in swift as a proctored test, using Lockdown Browser, and must be taken on campus in the locat tructor. It's closed-book, closed-notes with no access to any electronic devices or applications exception for the wo igned to take the test on. Question 30 [30] (SHORT ANSWER) In one statement, declare a variable named payRate and initialize it to 55.55. pe unice/hling-the-blank questions and Strutora selam implicitly refer to the Swift programming language his test is to be...
The volume of a sphere is given by V = (4/3)πrr3 , where r is the radius. Compute the volume of a sphere with a radius of 673 pm. State your answer in units of m^3
A sphere of radius r has surface area A = 4πr2 and volume V = (4/3) πr3. The radius of sphere 2 is double the radius of sphere 1. (a)What is the ratio of the areas, A2/A1? (b)What is the ratio of the volumes, V2/V1?