Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please complete the following computer problem. You will list the: inputs, outpu

ID: 3679786 • Letter: P

Question

Please complete the following computer problem.

You will list the: inputs, outputs, pseudocode, flowchart, desk check

and C++ .cpp file.

Here is the problem:

Write a program that reads in the radius and length of a cylinder and computes the area and volume using the following formulas:

area = radius * radius * PI (Where PI is the constant that represents 3.14) volume = area * length

Here is a sample run:

Enter the radius and length of a cylinder: 5.5 12 (enter) The area is 94.985 The volume is 1139.82

Explanation / Answer

Method 1:

public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
double radius, length, area, volume;
System.out.print("Enter the radius of the cylinder:");
radius = s.nextDouble();
System.out.print("Enter the length of the cylinder:");
length = s.nextDouble();
area = radius * radius * Math.PI;
volume = area * length;
System.out.print("The area of the cylinder is " + area + " and the volume of the cylinder is " + volume);
}

Method 2:

import java.util.Scanner;
public class cylinder
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter radius of the cylinder: ");
double radius = input.nextDouble();
System.out.print("Enter length of the cylinder: ");
double length = input.nextDouble();
double volume = radius * radius * 3.14159 * length;
System.out.println("The volume of the cylinder is " + volume);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote