dimanche 29 novembre 2020

how to put multiple variables in if statement in java?

I'm super new to programming , I'm making a program to calculate If two lines are parallel or not, the lines are considered parallel if a1 b2 = a2 b1 but I don't know how to put multiple variables in one if statement I have searched but I didn't find the answer can you help me please?

here is my code

double a1, b1, a2 , b2 ;
System.out.print("enter the first numbers");
a1 = input.nextDouble();
b2 = input.nextDouble();
System.out.print("enter the second numbers");
a2 = input.nextDouble();
b1 = input.nextDouble();
if (a1 && b2 == a2 && b1)
    System.out.print("the lines are parallel");
else System.out.print("the lines are not parallel");

Aucun commentaire:

Enregistrer un commentaire