Results 1 to 2 of 2

Thread: Cylinder

  1. #1
    Manikyr is offline Member
    Join Date
    Jan 2009
    Posts
    17
    Rep Power
    0

    Default 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?

    Java 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));
    	} 
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •