Question

I need to create a program in Java that can calculate:

The frustum volume.

The complete cone volume.

The program should be able to let the user input any value for h, and r. I was able to get the volume of the frustum but I can not find a way to make it calculate both the frustum and the whole cone.
10 Ejercicio: Tronco de Cono Un tronco de cono, es una figura geométrica resultante de cortar la parte superior de un cono no

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*
* The java program that prompts the user to enter the top radius, bottom radius, and height of the frustum then finds
* the volume of the frustram. Print the result on console.
* */
//FrustramVolume.java
import java.util.Scanner;
public class FrustramVolume
{
   public static void main(String[] args)
   {
       //create a Scanner class object
       Scanner input=new Scanner(System.in);
       //read top radius of frustram
       System.out.println("Enter r-value:");      
       double r=Double.parseDouble(input.nextLine());
       //read bottom radius of frustram
       System.out.println("Enter R-value:");
       double R=Double.parseDouble(input.nextLine());
       //read height of frustram
       System.out.println("Enter h-value:");
       double h=Double.parseDouble(input.nextLine());
       //calcualte volume of frustram shape
       double volume=(Math.PI/3)*(r*r+r*R+R*R)*h;
       System.out.printf("Volume of frustram :%.2f",volume);
   }

}
--------------------------------------------------------------------------------------------------

Sample Output:

Enter r-value:
5
Enter R-value:
6
Enter h-value:
7
Volume of frustram :667.06

-------------------------------------------------------------------------------------------------


/*The java program that prompts the user to enter the radius of the bottom of the cone then prompts for the height of the cone. Then, find the volume of the cone. Print the volume on the console.*/
//ConeVolume.java
import java.util.Scanner;
public class ConeVolume
{
   public static void main(String[] args)
   {
       //create a Scanner class object
       Scanner input=new Scanner(System.in);
       //read top radius of bottom
       System.out.println("Enter radius-value of bottom of cone:");      
       double r=Double.parseDouble(input.nextLine());
       //read bottom radius of frustram
       System.out.println("Enter height,h of the cone:");
       double h=Double.parseDouble(input.nextLine());

       //calcualte volume of cone shape
       double volume=(Math.PI/3)*(r*r)*h;
       System.out.printf("Volume of cone shape :%.2f",volume);
   }
}

------------------------------------------------------------------------------------------------

Sample Output:

Enter radius-value of the bottom of the cone:
5
Enter height,h of the cone:
6
The volume of cone shape: 157.08

Add a comment
Know the answer?
Add Answer to:
I need to create a program in Java that can calculate: The frustum volume. The complete...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • VCM CAR deM - RO mesine $+2010) CM + c 22. (See. 12.2) Tenemos un letrero...

    VCM CAR deM - RO mesine $+2010) CM + c 22. (See. 12.2) Tenemos un letrero (GAS) que pesa 200N y lo vamos a colgar usando una viga y un cable como se muestra en la figura La masa de la viga es uniforme pero no se conoce ni su masa, peso o largo. El cable no tiene masa. La fuerza del gozne (FG) que soporta a la vign es de 300N a 20º con la horizontal. La tensión que...

  • 2 points Save Answer Complete los siguientes espacios en blanco: En la siguiente figura una bala...

    2 points Save Answer Complete los siguientes espacios en blanco: En la siguiente figura una bala de masa de 10 g moviéndose verticalmente hacia arriba a 1000 m/s golpea y atraviesa un bloque de 5.0 kg inicialmente en reposo. La bala sale del bloque moviéndose directamente hacia arba a 400 m's A qué altura el bloque se eleva desde su posición inicial? Bullet Cecyeot Poses to Scers and Engineers Ed Hallday Resik & Wisker La altura que alcanza el bloque...

  • 3.0m- te -5.0m---- ya_19. (Sec. 12.2) Un sube y baja de 8.0m de largo y masa...

    3.0m- te -5.0m---- ya_19. (Sec. 12.2) Un sube y baja de 8.0m de largo y masa uniforme esta en equilibrio estático con un soporte que está a 3.0 de su extremo izquierdo y dos niños montados en sus extremos (ver figura). El niño más pequeño esta al extremo derecho y tiene masa de 40 Kg, y el niño más grande está en el extremo izquierdo y tiene masa de 80 Kg. ¿Cuál es la masa total del sube y baja?...

  • el coeficiente de correlación rny nos indica a. La fortaleza de la relación b. La c. La presencia de outliers en el eje de Y d. La naturaleza de la relación que X causa camblos en Y e. Ninguna de...

    el coeficiente de correlación rny nos indica a. La fortaleza de la relación b. La c. La presencia de outliers en el eje de Y d. La naturaleza de la relación que X causa camblos en Y e. Ninguna de las anteriores. cuál de las siguientes aseveracones cuadrática entre X, Y cercanía de los datos a la ecuación lineal entre X, Y se una desviación estándar s. Si una observación es tres veces el promedio (a saca de la muestra,...

  • create an editor in matlab program that prints in a single graph the sin(b) function for...

    create an editor in matlab program that prints in a single graph the sin(b) function for (is in the photo) and the approximate sine values ​​b with the taylor series Create the program in such a way that the graphics are smooth. Add title, label axes and create legend with meaningful information. Create the flowchart. Cree un programa editor que imprima en un solo gráfico la función de seno(B) para -AS Bsn y los valores de seno(B ) aproximados con...

  • 1. (15 pts.) El átomo de Terbio-159 tiene una masa de 158.925350 u. Determine la energía...

    1. (15 pts.) El átomo de Terbio-159 tiene una masa de 158.925350 u. Determine la energía de enlace/nucleón de Terbio-159. 2. (15 pts.) Un pote contiene sal yodada con cierta cantidad de Yodo-127 (isótopo estable) y otra cantidad menor de Yodo-131 (isótopo radiactivo). Suponga que hoy se mide la concentración de Yodo-131 en este pote, y se obtiene que la concentración es de 5.85 %. Determine la concentración de Yodo-131 en ese pote al cabo de 3 semanas 3. (20...

  • A new facility has 300 employees, parking is provided every 2 employees. All cars are standard si...

    A new facility has 300 employees, parking is provided every 2 employees. All cars are standard size, 6% are disabled. The available space is 200 ft. * 275 ft. Width. to. Number of spaces using module W 2 @ 45 degrees, cars 9 ' b. Number of spaces using module W 4 @ 90 degrees, cars 8'-6 " c. Number of spaces using module W 2 @ 90 degrees, cars 8'-6 " What is the impact of space required for...

  • 2. Calculate the mass of water vapor present in a 520 m3 volume room containing air...

    2. Calculate the mass of water vapor present in a 520 m3 volume room containing air at 27 ºC on a day where the relative humidity was 55%. (Vapor pressure at 27 ºC = 26.74 Torr) 3.Given that the air density at 0.987 bar and 27 ºC is 1,146 kg / m3, calculate the total moles of air and the total mass of the air found in 400 m 3. Also determine the molar fraction and the partial pressure of...

  • Calculate the normal force in A in the bar and pulley system shown. In O there is a "pin". Assume...

    Calculate the normal force in A in the bar and pulley system shown. In O there is a "pin". Assume that the surface at A is smooth or smooth. The mass value of the cylinder (m1) is equal to 20 kg. Evaluate the normal force at A for values of m1 (cylinder mass) from 10kg to 60kg at intervals of 10 (6 cases). Make a graph of Normal vs. cylinder mass (Normal in y / Mass in x). It is...

  • A horizontal bar is used to hold an object of m kg between two walls, as...

    A horizontal bar is used to hold an object of m kg between two walls, as shown in the figure. The equally exerted forces of the bar against the walls can be changed by adjusting the length from the bar. The system is only sustained by friction between the ends of the bar and the walls. The coefficient Static friction between these two is ms. Find the value of the forces F that guarantee the equilibrium of the system. with...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT