Alexis-Coria

Untitled

Aug 28th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EjercicioUno {
  4.  
  5. public static void main(String[] args) {
  6. int cuadranteI = 0,cuadranteII = 0,cuadranteIII = 0,cuadranteIV = 0,casoresp= 0;
  7. while (casoresp != 7) {
  8. casoresp=casos();
  9. switch (casoresp)
  10. {
  11. case 1:
  12. System.out.println("El conjunto de ejes cartesianos esta ubicado en el cuadrante I.");
  13. cuadranteI=cuadranteI+1;
  14. break;
  15. case 2:
  16. System.out.println("El conjunto de ejes cartesianos esta ubicado en el cuadrante II.");
  17. cuadranteII=cuadranteII+1;
  18. break;
  19. case 3:
  20. System.out.println("El conjunto de ejes cartesianos esta ubicado en el cuadrante III.");
  21. cuadranteIII=cuadranteIII+1;
  22. break;
  23. case 4:
  24. System.out.println("El conjunto de ejes cartesianos esta ubicado en el cuadrante IV.");
  25. cuadranteIV=cuadranteIV+1;
  26. break;
  27. case 5:
  28. System.out.println("El conjunto de ejes cartesianos esta ubicado en eje de las ordenadas.");
  29. break;
  30. case 6:
  31. System.out.println("El conjunto de ejes cartesianos esta ubicado en el eje del plano.");
  32. break;
  33. case 7:
  34. System.out.println("Puntos ubicados en el Cuadrante I: " + cuadranteI);
  35. System.out.println("Puntos ubicados en el Cuadrante II: " + cuadranteII);
  36. System.out.println("Puntos ubicados en el Cuadrante III: " + cuadranteIII);
  37. System.out.println("Puntos ubicados en el Cuadrante IV: " + cuadranteIV);
  38. break;
  39. default:
  40. System.out.println("Ingrese un valor.");
  41. }
  42.  
  43. }
  44.  
  45. }
  46.  
  47.  
  48.  
  49. public static int datos() {
  50. int teclado;
  51. Scanner sn = new Scanner(System.in);
  52. teclado = sn.nextInt();
  53. return teclado;
  54. }
  55.  
  56.  
  57. public static int casos() {
  58. double x,y;
  59. int resp = 0;
  60. System.out.println("Ingrese un punto X en el eje cartesiano. ");
  61. x = datos();
  62. System.out.println("Ingrese un punto y en el eje cartesiano. ");
  63. y = datos();
  64. if ((x > 0))
  65. {
  66. if (y<0)
  67. {
  68. resp=4;
  69. }
  70. if (y>0)
  71. {
  72. resp=1;
  73. }
  74. }
  75. if ((x < 0))
  76. {
  77. if (y<0)
  78. {
  79. resp=3;
  80. }
  81. if (y>0)
  82. {
  83. resp=2;
  84. }
  85. }
  86. if ((x == 0))
  87. {
  88. if (y<0)
  89. {
  90. resp=6;
  91. }
  92. if (y>0)
  93. {
  94. resp=6;
  95. }
  96. }
  97. if ((y == 0))
  98. {
  99. if (x<0)
  100. {
  101. resp=5;
  102. }
  103. if (x>0)
  104. {
  105. resp=5;
  106. }
  107. }
  108.  
  109. if ((x == 0) && (y == 0))
  110. { resp=7;
  111. }
  112.  
  113. return resp;
  114. }
  115. }
  116.  
Advertisement
Add Comment
Please, Sign In to add comment