Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tp0;
- import java.util.Scanner;
- public class Tp0ej1a {
- public static void main(String[] args) {
- System.out.println("PROGRAMA DETECTOR DE PUNTOS EN EL PLANO CARTESIANO");
- Scanner scanner= new Scanner(System.in);
- double xp;
- double yp;
- int cant1=0;
- int cant2=0;
- int cant3=0;
- int cant4=0;
- do {
- System.out.println("INGRESE X: ");
- xp=scanner.nextDouble();
- System.out.println("INGRESE Y: ");
- yp=scanner.nextDouble();
- if (xp>0&&yp>0) {
- cant1++;
- }else {
- if (xp<0&&yp>0) {
- cant2++;
- }else {
- if (xp<0&&yp<0) {
- cant3++;
- }else {
- if (xp>0&&yp<0) {
- cant4++;
- }
- }
- }
- }
- if (xp>0&&yp>0)
- System.out.println("EL PUNTO ("+xp+","+yp+") SE ENCUENTRA EN EL PRIMER CUADRANTE");
- if (xp<0&&yp>0)
- System.out.println("EL PUNTO ("+xp+","+yp+") SE ENCUENTRA EN EL SEGUNDO CUADRANTE");
- if (xp<0&&yp<0)
- System.out.println("EL PUNTO ("+xp+","+yp+") SE ENCUENTRA EN EL TERCER CUADRANTE");
- if (xp>0&&yp<0)
- System.out.println("EL PUNTO ("+xp+","+yp+") SE ENCUENTRA EN EL CUARTO CUADRANTE");
- if (xp==0&&yp>0)
- System.out.println("EL PUNTO "+yp+" SE ENCUENTRA SOBRE EL EJE 'Y' POSITIVO");
- if (xp==0&&yp<0)
- System.out.println("EL PUNTO "+yp+" SE ENCUENTRA SOBRE EL EJE 'Y' NEGATIVO");
- if (xp>0&&yp==0)
- System.out.println("EL PUNTO "+xp+" SE ENCUENTRA SOBRE EL EJE 'X' POSITIVO");
- if (xp<0&&yp==0)
- System.out.println("EL PUNTO "+xp+" SE ENCUENTRA SOBRE EL EJE 'X' NEGATIVO");
- }while(xp!=0||yp!=0);
- System.out.println("ORIGEN DEL SISTEMA DE CORDENADAS ·FIN DEL PROGRAMA· ");
- System.out.println("PRIMER CUADRANTE/CANTIDAD: "+cant1);
- System.out.println("SEGUNDO CUADRANTE/CANTIDAD: "+cant2);
- System.out.println("TERCER CUADRANTE/CANTIDAD: "+cant3);
- System.out.println("CUARTO CUADRANTE/CANTIDAD: "+cant4);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement