martes, 8 de junio de 2010

OPERACIONES ARITMETICAS VERSION 2

import javax.swing.JOptionPane;
public class aritmetica2
{
public static void main (String args [ ])
{

// DECLARACION DE VARIABLES
float num1, num2, suma, resta, multi, division;
String entrada, name;

// ENTRADA DE DATOS
name = JOptionPane.showInputDialog (" Cómo te llamas ?.....");

entrada = JOptionPane.showInputDialog ("Teclea el primer valor ");
num1 = Float.parseFloat(entrada);
entrada = JOptionPane.showInputDialog ("Teclea el segundo valor ");
num2 = Float.parseFloat(entrada);

// OPERACIONES ARITMETICAS
suma = num1 + num2;
resta = num1- num2;
multi = num1 * num2;
division = num1 / num2;

// SALIDA DE DATOS
JOptionPane.showMessageDialog
(null,"LOS RESULTADOS DE LAS OPERACIONES ARITMETICAS SON: \n \n La suma de " +num1 + " + " +num2 +" = " + String.format("%.2f",suma) +"\n La resta de " +num1 + " - " +num2 +" = " + String.format("%.2f",resta)+"\n La multiplicacion de " +num1 +" * " +num2 +" = " +multi+ String.format("%.2f",multi) +"\n La división de " +num1 +" / " +num2 +" = " + String.format("%.2f",division) +"\n \n Realizadas por " +name);
System.exit(0);
}
}

No hay comentarios:

Publicar un comentario