Se está descargando tu SlideShare. ×

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Cargando en…3
×

1 de 2 Anuncio

# Write a Function procedure to calculate the surface area of a right ci.docx

Write a Function procedure to calculate the surface area of a right circular cone, given its side dimension, s, and bottom radius, r: A = pir^2s On a worksheet, enter a radius and side length into labeled input cells, and use your function procedure in a labeled output cell. Pass the inputs as arguments to your function. Be sure to show the units of your inputs and outputs.
Solution
import java.util.Scanner;
public class SurfaceArea //function to calculate surface area of right circular cone
{
public static void main(String[] args)
{
float r, h;
Scanner s = new Scanner(System.in);
System.out.print(\"Enter the side of cone:\");
h = s.nextInt(); //side of a cone
r = s.nextInt(); //bottom radius of cone
SurfaceArea b=new SurfaceArea(); //object to invoke the function called
b.compute(h,r); //calling function and passing arguements
}
void compute(float h,float r)
{
double area, pi = 3.14;
area = (pi * r * h) + (pi * r * r);
System.out.println(\"Surface Area of cone:\"+area);
}
}
.

Write a Function procedure to calculate the surface area of a right circular cone, given its side dimension, s, and bottom radius, r: A = pir^2s On a worksheet, enter a radius and side length into labeled input cells, and use your function procedure in a labeled output cell. Pass the inputs as arguments to your function. Be sure to show the units of your inputs and outputs.
Solution
import java.util.Scanner;
public class SurfaceArea //function to calculate surface area of right circular cone
{
public static void main(String[] args)
{
float r, h;
Scanner s = new Scanner(System.in);
System.out.print(\"Enter the side of cone:\");
h = s.nextInt(); //side of a cone
r = s.nextInt(); //bottom radius of cone
SurfaceArea b=new SurfaceArea(); //object to invoke the function called
b.compute(h,r); //calling function and passing arguements
}
void compute(float h,float r)
{
double area, pi = 3.14;
area = (pi * r * h) + (pi * r * r);
System.out.println(\"Surface Area of cone:\"+area);
}
}
.

Anuncio
Anuncio