sábado, 6 de julio de 2013

TRY

 INSTRUCCION  TRY

EJERCICIO  "4"


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edad;

import javax.swing.JOptionPane;
public class Edad {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
      int a, b, c;
        try{
        System.out.println("   MAYOR O MENOR DE EDAD");
       
        a =Integer.parseInt(JOptionPane.showInputDialog("Ingresa el año actual:"));
       
        b =Integer.parseInt(JOptionPane.showInputDialog("Ingresa el año de nacimiento:"));
     
        c=a-b;
         System.out.println("TIENES " + c + "  AÑOS");
       
         if (c>17){
             System.out.println("ERES MAYOR DE EDAD");
         }
         else
         {
             System.out.println("ERES MENOR DE EDAD");
           
         }
         }catch (NumberFormatException ex){
        JOptionPane.showInputDialog("Por favor ingresa numero");
     
    }

    }
}



No hay comentarios:

Publicar un comentario