@redm23
de pronto esto te sirve...
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package io;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author user
*/
public class IO {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
double dBase = 0.0, dAltura = 0.0, dArea = 0.0;
int iBase = 0, iAltura = 0, iArea = 0;
long lBase = 0, lAltura = 0, lArea = 0;
int metodo = 0;
try {
System.out.print("Con que tipo de variables desea calcular el area del triangulo?n1.n2.n3.");
metodo = Integer.parseInt(br.readLine());
switch (metodo) {
case 1:
System.out.print("Metodo por doubles. ");
System.out.print("Ingresar base: ");
dBase = Double.parseDouble(br.readLine());
System.out.print("Ingresar altura: ");
dAltura = Double.parseDouble(br.readLine());
System.out.println("El area del rectangulo es " + area(dBase, dAltura));
break;
case 2:
System.out.print("Metodo por enteros. ");
System.out.print("Ingresar base: ");
iBase = Integer.parseInt(br.readLine());
System.out.print("Ingresar altura: ");
iAltura = Integer.parseInt(br.readLine());
System.out.println("El area del rectangulo es " + area(iBase, iAltura));
break;
case 3:
System.out.print("Metodo por longs. ");
System.out.print("Ingresar base: ");
lBase = Long.parseLong(br.readLine());
System.out.print("Ingresar altura: ");
lAltura = Long.parseLong(br.readLine());
System.out.println("El area del rectangulo es " + area(lBase, lAltura));
break;
}
} catch (IOException e) {
System.out.println("Error en datos introducidos");
}
}
public static int area(int base, int altura) {
return (base * altura) / 2;
}
public static double area(double base, double altura) {
return (base * altura) / 2;
}
public static long area(long base, long altura) {
return (base * altura) / 2;
}
}