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 double leerDouble(Scanner reader) {
  11. return reader.nextDouble();
  12. }
  13.  
  14. public static double suma(double x, double y){
  15. double suma = x + y;
  16. return suma;
  17. }
  18.  
  19. static double resta(double x, double y){
  20. double resta = x - y;
  21. return resta;
  22. }
  23.  
  24. static double multiplica(double x, double y){
  25. double multiplica = x * y;
  26. return multiplica;
  27. }
  28.  
  29. static double cuadrado(double x){
  30. double cuadrado = Math.sqrt(x);
  31. return cuadrado;
  32. }
  33.  
  34. public static void main (String[] args) throws java.lang.Exception {
  35.  
  36. Scanner lectura = new Scanner(System.in);
  37. double x = leerDouble(lectura);
  38. double y = leerDouble(lectura);
  39. System.out.println(x);
  40. System.out.println(y);
  41. //operaciones:
  42.  
  43. System.out.println("resta: " + resta(x, y));
  44. System.out.println("suma: " + suma(x, y));
  45. System.out.println("multiplica: " + multiplica(x, y));
  46. System.out.println("cuadrado: " + cuadrado(x));
  47.  
  48. }
  49. }
Success #stdin #stdout 0.19s 60828KB
stdin
86
74
stdout
86.0
74.0
resta: 12.0
suma: 160.0
multiplica: 6364.0
cuadrado: 9.273618495495704