-
Cylinder
Hi!
My assignment for this weekend is to count out a cylinders volume.
What do you think about my code? Should I change it somehow?
Code:
import javax.swing.*;
import java.text.*;
import java.util.*;
public class NewEmpty11 {
public static void main (String[] arg) {
String indata = JOptionPane.showInputDialog("Ange cylinderns radie och höjd:");
Scanner sc = new Scanner(indata);
double radie = sc.nextDouble();
double höjd = sc.nextDouble();
double volym = Math.PI * Math.pow(radie,2) * höjd;
NumberFormat r = NumberFormat.getInstance();
r.setMaximumFractionDigits(2);
r.setMinimumFractionDigits(2);
JOptionPane.showMessageDialog(null, "Volymen av cylindern är "
+ r.format(volym));
}
}
-
What do YOU think about it? Is your code working well when you've tested it? If so, don't change it. If not, then please tell us your specific problem. Best of luck!