Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

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

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige

Hier ansehen

1 von 2 Anzeige

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

Herunterladen, um offline zu lesen

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
System.out.print(\"Enter the radius of 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
System.out.print(\"Enter the radius of 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);
}
}
.

Anzeige
Anzeige

Weitere Verwandte Inhalte

Ähnlich wie Write a Function procedure to calculate the surface area of a right ci.docx (20)

Weitere von lez31palka (20)

Anzeige

Aktuellste (20)

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

  1. 1. 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 System.out.print("Enter the radius of 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); } }

×