fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. //Luis Fernando García Ávalos
  13. Scanner scanner = new Scanner(System.in);
  14. System.out.println("Ingrese el primer número: ");
  15. double num1 = scanner.nextDouble();
  16. System.out.println("Ingrese el segundo número: ");
  17. double num2 = scanner.nextDouble();
  18. System.out.println("Ingrese el tercer número: ");
  19. double num3 = scanner.nextDouble();
  20.  
  21. double suma = num1 + num2 + num3;
  22. double resta = num1 - num2 - num3;
  23. double multiplicacion = num1 * num2 * num3;
  24.  
  25. double division;
  26. if (num2 != 0 && num3 != 0) {
  27. division = num1 / num2 / num3;
  28. } else {
  29. division = Double.NaN;
  30. System.out.println("Error: División por cero");
  31. }
  32.  
  33. System.out.println("Suma: " + suma);
  34. System.out.println("Resta: " + resta);
  35. System.out.println("Multiplicación: " + multiplicacion);
  36. System.out.println("División: " + division);
  37.  
  38. scanner.close();
  39. }
  40. }
Success #stdin #stdout 0.18s 58852KB
stdin
78
89
61
38
stdout
Ingrese el primer número: 
Ingrese el segundo número: 
Ingrese el tercer número: 
Suma: 228.0
Resta: -72.0
Multiplicación: 423462.0
División: 0.01436728679314791