|
programming import java.util.Scanner;
public class rectangle
{
public static void main (String[] args)
{
double int x1 = 0;
double int x2 = 0;
double int x3 = 0;
double int y1 = 0;
double int y2 = 0;
double int y3 = 0;
Scanner scan = new Scanner (System.in);
if( x1 != 0)
{
System.out.println ("enter x1: ");
x1 = scan.nextInt();
}
if(y1 != 0)
{
System.out.println ("enter y1: " );
y1 = scan.nextInt();
}
if(x2 != 0)
{
System.out.println ("enter x2: " );
x2 = scan.nextInt();
}
if(y2 != 0)
{
System.out.println ("enter y2: " );
y2 = scan.nextInt();
}
if(x3 != 0)
{
System.out.println ("enter x3: " );
x3 = scan.nextInt();
}
if(y3 != 0)
{
System.out.println ("enter y3: " );
y3 = scan.nextInt();
}
if (Distance3 > Distance 1 && Distance3 > Distance2);
{
Distance1= Math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
Distance2= Math.sqrt(((x2 - x3) * (x2 - x3)) + ((y2 - y3) * (y2 - y3)));
Distance3= Math.sqrt(((x1 - x3) * (x1 - x3)) + ((y1 - y3) * (y1 - y3)));
Area = Distance1 * Distance2;
else
System.out.println ("This is anything, but a rectangle");
}
}
}
can you tell me whats wrong with this
[ ] Want to answer more questions in the Technology category? Maybe give some free advice about: Internet & Web Design?
Use "double" or "int", not "double int". Since "nextInt" presumably returns an int, you should probably use that.
You shouldn't end "if" statements with semicolons. Even without the semicolon, the distanceX variables need to be defined BEFORE the "if". And the "else" is supposed to be after the "if". Probably you want something like this (starting at line 53):
Distance1=...;
Distance2=...;
Distance3=...;
Area=...;
//You wrongly used "distance 1" instead of a variable name below.
if(distance3>distance1...)
{
System.out.println("This is a rectangle.");
}
else
{
System.out.println("This is not a rectangle.");
} ]
More Questions: |