Advertisement
ABE12unju

Ejercicio1practico0

Aug 31st, 2021
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. package tp0;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Tp0ej1a {
  6.  
  7.     public static void main(String[] args) {
  8.         System.out.println("PROGRAMA DETECTOR DE PUNTOS EN EL PLANO CARTESIANO");
  9.         Scanner scanner= new Scanner(System.in);
  10.         double xp;
  11.         double yp;
  12.         int cant1=0;
  13.         int cant2=0;
  14.         int cant3=0;
  15.         int cant4=0;
  16.         do {
  17.             System.out.println("INGRESE X: ");
  18.             xp=scanner.nextDouble();
  19.        
  20.             System.out.println("INGRESE Y: ");
  21.             yp=scanner.nextDouble();
  22.            
  23.             if (xp>0&&yp>0) {
  24.                 cant1++;
  25.             }else {
  26.                 if (xp<0&&yp>0) {
  27.                     cant2++;
  28.                 }else {
  29.                     if (xp<0&&yp<0) {
  30.                         cant3++;
  31.                     }else {
  32.                         if (xp>0&&yp<0) {
  33.                             cant4++;
  34.                         }
  35.                     }
  36.                 }
  37.             }
  38.             if (xp>0&&yp>0)
  39.                 System.out.println("EL PUNTO ("+xp+","+yp+") SE ENCUENTRA EN EL PRIMER CUADRANTE");
  40.             if (xp<0&&yp>0)
  41.                 System.out.println("EL PUNTO ("+xp+","+yp+") SE ENCUENTRA EN EL SEGUNDO CUADRANTE");
  42.             if (xp<0&&yp<0)
  43.                 System.out.println("EL PUNTO ("+xp+","+yp+") SE ENCUENTRA EN EL TERCER CUADRANTE");
  44.             if (xp>0&&yp<0)
  45.                 System.out.println("EL PUNTO ("+xp+","+yp+") SE ENCUENTRA EN EL CUARTO CUADRANTE");
  46.            
  47.             if (xp==0&&yp>0)
  48.                 System.out.println("EL PUNTO "+yp+" SE ENCUENTRA SOBRE EL EJE 'Y' POSITIVO");
  49.             if (xp==0&&yp<0)
  50.                 System.out.println("EL PUNTO "+yp+" SE ENCUENTRA SOBRE EL EJE 'Y' NEGATIVO");
  51.             if (xp>0&&yp==0)
  52.                 System.out.println("EL PUNTO "+xp+" SE ENCUENTRA SOBRE EL EJE 'X' POSITIVO");
  53.             if (xp<0&&yp==0)
  54.                 System.out.println("EL PUNTO "+xp+" SE ENCUENTRA SOBRE EL EJE 'X' NEGATIVO");
  55.            
  56.         }while(xp!=0||yp!=0);
  57.         System.out.println("ORIGEN DEL SISTEMA DE CORDENADAS ·FIN DEL PROGRAMA· ");
  58.         System.out.println("PRIMER CUADRANTE/CANTIDAD: "+cant1);
  59.         System.out.println("SEGUNDO CUADRANTE/CANTIDAD: "+cant2);
  60.         System.out.println("TERCER CUADRANTE/CANTIDAD: "+cant3);
  61.         System.out.println("CUARTO CUADRANTE/CANTIDAD: "+cant4);
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement