Ask Question
6 July, 05:03

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.

+3
Answers (1)
  1. 6 July, 08:32
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers