This assignment should use JOptionPane to do input and outpu

This assignment should use JOptionPane to do input and output Write a program that reads in the radius and length of a cylinder and computes volume using the following formulas: area = radius * radius * PI volume = area * length Hint: Constant PI is 3.14159, or you can use Math.PI

Solution

Answer:

import javax.swing.*;
class Cylinder {

public static void main (String args[]){
String radiusofstring = JOptionPane.showInputDialog(\"Enter radius of the cylinder in double form\");
double radius = Double.parseDouble(radiusofstring);
String lengthofstring = JOptionPane.showInputDialog(\"Enter length of the radius in double form\");
double length = Double.parseDouble(lengthofstring);
final double PI = 3.14159;
double total_area = radius * radius * PI ;
double volume = total_area * length ;
JOptionPane.showMessageDialog(null,\"The Volume of Cylinder = \" + volume , \"Output\" , JOptionPane.INFORMATION_MESSAGE );   
}
}

This assignment should use JOptionPane to do input and output Write a program that reads in the radius and length of a cylinder and computes volume using the fo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site