Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. package java01;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Code_anonying{
  6.  
  7. public static void main (String[] args){
  8.  
  9. Scanner sc = new Scanner(System.in);
  10.  
  11. System.out.println("Digite el dato double: ");
  12. double num1 = sc.nextDouble();
  13. System.out.println("Su numero es: " + num1);
  14.  
  15.  
  16.  
  17. }
  18. }
  19.  
  20. Exception in thread "main" java.util.InputMismatchException
  21.  
  22. at java.base/java.util.Scanner.throwFor(Scanner.java:939)
  23. at java.base/java.util.Scanner.next(Scanner.java:1594)
  24. at java.base/java.util.Scanner.nextDouble(Scanner.java:2564)
  25. at java01.Code_anonying.main(Code_anonying.java:12)
  26.  
  27. AppDataLocalNetBeansCache10.0executor-snippetsrun.xml:111: The following error occurred while executing this line:
  28.  
  29. AppDataLocalNetBeansCache10.0executor-snippetsrun.xml:68: Java returned: 1
  30.  
  31. Scanner sc = new Scanner(System.in);
  32. System.out.println("Digite el dato double: ");
  33. try {
  34. double num1 = sc.nextDouble();
  35. System.out.println("Su numero es: " + num1);
  36. } catch (Exception e) {
  37. System.out.println("Error de digitación ");
  38. }
  39.  
  40. import java.text.NumberFormat;
  41. import java.util.Locale;
  42.  
  43. ...
  44. código
  45. ...
  46.  
  47. Locale spanish = new Locale("es", "ES");
  48. NumberFormat nf= NumberFormat.getInstance(spanish);
  49. Scanner sc = new Scanner(System.in);
  50. System.out.println("Digite el dato double: ");
  51. double num1 = sc.nextDouble();
  52. System.out.println("Su numero es: " + num1);
  53. System.out.println("Error de digitación ");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement