Ask Question
29 September, 02:10

Rearrange the statements in the following order so that the program prompts the user to input: a. The height of the base of a cylinder b. The radius of the base of a cylinder The program then outputs (in order) : a. The volume of the cylinder. b. The surface area of the cylinder c. Format the output to two decimal places.

+2
Answers (1)
  1. 29 September, 02:59
    0
    import java. util. Scanner;

    public class num5 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter base heigth of the cylinder");

    double heigth = in. nextDouble ();

    System. out. println ("Enter radius of the cylinder");

    double radius = in. nextDouble ();

    / / vol = pi*r2*h area = 2π r h + 2π r².

    double volCylinder = Math. PI * (radius*radius) * heigth;

    double surfaceAreaCylinder = (2*Math. PI*radius*heigth) +

    (2*Math. PI * (radius*radius));

    / / Outputs

    System. out. printf ("The Vol of the cylinder %.2f / n", volCylinder);

    System. out. printf ("The surface Area %.2f / n", surfaceAreaCylinder);

    }

    }

    Explanation:

    The program is written in Java.

    Prompt user for height and radius of the cylinder. Store in the repective variables

    Calculate Volume of the cylinder

    Calculate Surface Area

    Using Java's printf function to output result to 2 decimal places
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Rearrange the statements in the following order so that the program prompts the user to input: a. The height of the base of a cylinder b. ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers