Exception in thread "main" java.lang.NumberFormatException: For input string: ""
Publicado por pepe (15 intervenciones) el 22/02/2021 05:41:28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package actuvudad.pkg1.pkg2;
import java.util.Scanner;
/**
*
* @author aryda
*/
public class Actuvudad12 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
/**
* @param args the command line arguments
*/
// TODO code application logic here
int opc;
Scanner entrada = new Scanner(System.in);
do{
System.out.println("*** Bienvenido!!! ***");
System.out.println("1. Resolver un cilindro ");
System.out.println("2. Resolver un triangulo cualquiera");
System.out.println("3. Conversion de ºC A ºf");
System.out.println("4. calcular la sumatoria de 1 a N");
System.out.println("5. Calcular el promedio de N calificaciones");
System.out.println("6. Leer la CURP y mostrar el sexo y estado de nacimiento");
System.out.println("7. Calcular el Indice de Masa Corporal y mostrar estado de obesidad");
System.out.println("8. Salir...");
System.out.println("Elija su ocpcion:");
opc = Integer.parseInt(entrada.nextLine());
switch(opc){
case 1:{
System.out.println("Resolver un cilindro");
resol_cilindro();
}
break;
case 2:{
System.out.println("Resolver un triangulo");
Triangulo();
}break;
case 3:{
System.out.println("Conversion de ºC a ºF");
float gradosC;
System.out.println("Ingrese sus grados Celcious");
gradosC = entrada.nextFloat();
System.out.println("Los grados Farenheit son :" + conversion(gradosC));
}
break;
}
}while(opc!=8);
}
//Métodos de la clase
//** Area de la circunferencia
public static void resol_cilindro(){
double radio, Altura;
double AreaBase;
double volumen, PI = 3.1416;
double a;
Scanner entrada = new Scanner (System.in);
System.out.println("Ingresa el radio del cilindro");
radio = entrada.nextDouble();
System.out.println("Ingresa la altura del cilindro");
Altura = entrada.nextDouble();
AreaBase = PI * radio * radio;
volumen = AreaBase * Altura;
System.out.println("El volumen del cilindro es" + volumen+ "cm3");
System.out.println("El area de la base es " +AreaBase+"cm2");
}
//** Perimetro de la circunferencia
static void Triangulo(){
float base,altura,Respuesta;
Scanner entrada = new Scanner (System.in);
System.out.println("Ingrese la base del triangulo");
base = entrada.nextFloat();
System.out.println("Ingrese la altura del triangulo");
altura = entrada.nextFloat();
Respuesta = base * altura / 2;
System.out.println("El area del triangulo es de " + Respuesta);
}
static float conversion(float C){
float F;
F = (C * 9 / 5) + 32;
return (F);
}
// TODO code application logic here
}
en el case 3 me sale la respuesta que es correcta pero me sale este error alguien que me ayude :C
Exception in thread "main" java.lang.NumberFormatException: For input string: ""

Valora esta pregunta


0