Софтуерно Инженерство
Loading...
+ Нов въпрос
chaneto avatar chaneto -3 Точки

Къде греша??? "Point on Rectangle Border"

package vlojeniuslovnikonstrukci;

import java.util.Scanner;

public class CLASS1pointonrectangle {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double x1 = Double.parseDouble(scanner.nextLine());
        double y1 = Double.parseDouble(scanner.nextLine());
        double x2 = Double.parseDouble(scanner.nextLine());
        double y2 = Double.parseDouble(scanner.nextLine());
        double x = Double.parseDouble(scanner.nextLine());
        double y = Double.parseDouble(scanner.nextLine());
        if (x == x1 || x == x2 && y>= y1 && y <= y2) {
            System.out.println("Border");
        }else if (y == y1 || y == y2 && x >= x1 && x <= x2) {
            System.out.println("Border");
        }else
        { System.out.println("Inside / Outside");
        }

      }
    }

Тагове:
chaneto avatar chaneto -3 Точки

Справих  се, ето по този начин ми даде 100/100:

package vlojeniuslovnikonstrukci;

import java.util.Scanner;

public class CLASS1pointonrectangle {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double x1 = Double.parseDouble(scanner.nextLine());
        double y1 = Double.parseDouble(scanner.nextLine());
        double x2 = Double.parseDouble(scanner.nextLine());
        double y2 = Double.parseDouble(scanner.nextLine());
        double x = Double.parseDouble(scanner.nextLine());
        double y = Double.parseDouble(scanner.nextLine());
        if ((x == x1 || x == x2 || y == y1 || y == y2) && y >= y1 && y <= y2 && x >= x1 && x <= x2){
            System.out.println("Border");
        }else{ System.out.println("Inside / Outside");}
        }

    }

-2