Advertisement
ARIELCARRARO

VolumenCono.java

Jan 26th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. /**
  2.  * @file VolumenCono.java
  3.  * @version 0.0.1
  4.  * @author Ariel Carraro
  5.  * @date   26-enero-2013
  6.  * @url    
  7.  * @description Programa que calcula el volumen de un cono
  8.  */
  9.  
  10.  
  11. import javax.swing.JOptionPane;
  12. import javax.swing.*;
  13.  
  14. public class VolumenCono{
  15.    
  16.     public static void main(String[] args) {
  17.          try{
  18.          double radio=Double.parseDouble(JOptionPane.showInputDialog("Introduce radio:"));  
  19.          double altura=Double.parseDouble(JOptionPane.showInputDialog("Introduce altura:"));  
  20.          JOptionPane.showMessageDialog(null,"Volumen obtenido\n"+String.valueOf(volumen(radio,altura)),"Aviso", JOptionPane.PLAIN_MESSAGE,new ImageIcon("imagen.jpg"));
  21.          System.exit(0);
  22.          }    
  23.          catch(Exception ex){
  24.             JOptionPane.showMessageDialog(null,ex.getCause().toString(),"Aviso", JOptionPane.ERROR_MESSAGE,new ImageIcon("imagen.jpg"));
  25.          }
  26.     }
  27.    
  28.     public static double volumen(double r,double h){
  29.         return (Math.PI*(r*r)*h)/3;
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement