Множественное значение в операторе «если»

Я пытаюсь реализовать, если наклон один положительный (больше нуля), а slope1 положительный, умножьте на -1

'Исключение в потоке "main" java.lang.Error: Неразрешенные проблемы компиляции: Синтаксическая ошибка токена ";",. ожидаемый slope1 не может быть разрешен или не является полем

в LinearSlopeFinder.main (LinearSlopeFinder.java:25) ;

я пробовал использовать вместо этого ",", но без кубиков

import java.util.Scanner;

public class LinearSlopeFinder {
    public static void main(String[]args){
        double x1, y1, x2, y2, n1, equation, constant = 0 ;
        double slope, slope1, slopeAns;
        Scanner myScanner = new Scanner(System.in);

        System.out.print("    What is the first set of cordinants? example: x,y ... ");
        String coordinate1 = myScanner.nextLine();
        String coordinates[] = coordinate1.split(",");
        x1 = Integer.parseInt(coordinates[0]);
        y1 = Integer.parseInt(coordinates[1]);

        System.out.print("    What is the second set of cordinants? example: x,y ... ");
        String coordinate2 = myScanner.nextLine();
        String coordinates1[] = coordinate2.split(",");
        x2 = Integer.parseInt(coordinates1[0]);
        y2 = Integer.parseInt(coordinates1[1]);

        //remember it is Rise over Run Y's over X's
        slope = (y1-y2);
        slope1= (x1-x2);
        slopeAns= slope / slope1 ;
            //below is the part that is not compiling but I am trying to insert
        if ( slope > 0 ; slope1 > 0 ){
            slope = slope * -1;
            slope1 = slope1 * -1;
        }
0
задан PythagorasPi 22 October 2011 в 05:33
поделиться