Ask 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. 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.

+1
Answers (1)
  1. 1 June, 06:27
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers