Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import java.util.Scanner;
  2. import javax.swing.JOptionPane;
  3. import java.text.DecimalFormat;
  4.  
  5. public class areavolume {
  6.  
  7. static final float PI = 3.14159265f;
  8.  
  9. public static void main(String[] args) {
  10.  
  11. Scanner soma = new Scanner(System.in);
  12.  
  13.  
  14. String raio;
  15.  
  16. System.out.println("Digite o raio da esfera:");
  17. raio = soma.nextLine();
  18.  
  19. double c = Double.parseDouble(raio);
  20.  
  21.  
  22. double area = (4*c*c*PI);
  23. double volume = (4*c*c*c*PI/3);
  24.  
  25. DecimalFormat df = new DecimalFormat("###,##0.00");
  26. JOptionPane.showMessageDialog(null,"A area e:\n\n"+(df.format(area)));
  27. JOptionPane.showMessageDialog(null,"O volume e:\n\n"+(df.format(volume)));
  28.  
  29.  
  30.  
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement