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. static double resta(double n, double m){
  14. return (n - m); }
  15.  
  16. static double suma(double n, double m){
  17. return (n + m); }
  18.  
  19. static double multiplica(double n, double m){
  20. return (n * m); }
  21.  
  22. static double cuadrado(double n){
  23. return (n * n); }
  24. public static void main (String[] args) throws java.lang.Exception
  25.  
  26. {
  27. Scanner lectura = new Scanner(System.in);
  28. double x = leerDouble(lectura);
  29. double y = leerDouble(lectura);
  30. System.out.println(x);
  31. System.out.println(y);
  32. //operaciones:
  33.  
  34. System.out.println("resta: " + resta(x, y));
  35. System.out.println("suma: " + suma(x, y));
  36. System.out.println("multiplica: " + multiplica(x, y));
  37. System.out.println("cuadrado: " + cuadrado(x));
  38.  
  39. } // end main
  40. } // end class
Success #stdin #stdout 0.18s 60832KB
stdin
234
111
stdout
234.0
111.0
resta: 123.0
suma: 345.0
multiplica: 25974.0
cuadrado: 54756.0