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 class AreaPiscina {
  11.  
  12. static double calcularArea(double raio){
  13. return((raio >= 0) ? Math.PI * Math.pow(raio, 2) : -1);
  14. }
  15.  
  16. }
  17.  
  18. public static class AreaCasa {
  19. //preço do metro quadrado
  20. static double valorM2 = 1500;
  21.  
  22. //calcula a área da casa
  23. static double CasaRet(double l_sala, double c_quarto) {
  24. double area_s; //área da sala
  25. double area_q; //área do quarto
  26. double area_t = 0; //área do total
  27.  
  28. if(l_sala < 0 || c_quarto < 0)
  29. System.out.println("Erro!");
  30.  
  31. else{
  32. area_s = l_sala * l_sala; //calcula area da sala
  33. area_q = c_quarto * (l_sala/2); //calcula area do quarto
  34. area_t = area_s + 2 * area_q; //calcula a area total
  35. }
  36. return(area_t);
  37. }
  38. }
  39.  
  40. static double Area(double lateral_1, double lateral_2, double pis_raio) {
  41. return(AreaCasa.CasaRet(lateral_1, lateral_2) + AreaPiscina.calcularArea(pis_raio));
  42. }
  43.  
  44. public static void main (String[] args) throws java.lang.Exception
  45. {
  46. System.out.println(Area(21.43, 33.4, 2.0));
  47. }
  48. }
Success #stdin #stdout 0.12s 320576KB
stdin
Standard input is empty
stdout
1187.573270614359