importjava.util.Scanner;publicclassTriangles{publicstaticvoidmain(String[]args){doubleX1,Y1,X2,Y2,X3,Y3,POT;finaldoubleminX=0;finaldoubleminY=0;finaldoublemaxX=40;finaldo...
import java.util.Scanner;
public class Triangles
{
public static void main(String[] args)
{
double X1,Y1,X2,Y2,X3,Y3,POT;
final double minX = 0;
final double minY = 0;
final double maxX = 40;
final double maxY = 40;
Scanner input = new Scanner(System.in);
System.out.print("Tis program calculates the perimeter of a Triangle.");
if (X1 >= minX || X1 <= maxX)
System.out.print("Enter X of point 1:");
else
{
System.out.println("Your X1 value is not accpect for this program, please enter the value between 0 to 40.");
X1 = input.nextDouble();
}
if(Y1 >= minY || Y1 <= maxY)
System.out.print("Enter Y of point 1:");
else
{
System.out.println("Your Y1 value is not accpect for this program, please enter the value between 0 to 40.");
Y1 = input.nextDouble();
}
if(X2 >= minX || X2 <= maxX)
System.out.print("Enter X of point 2:");
else
{
System.out.println("Your X2 value is not accpect for this program, please enter the value between 0 to 40.");
X2 = input.nextDouble();
}
if(Y2 >= minY || Y2 <= maxY)
System.out.print("Enter X of point 2:");
else
{
System.out.println("Your Y2 value is not accpect for this program, please enter the value between 0 to 40.");
Y2 = input.nextDouble();
}
if(X3 >= minX || X3 <= maxX)
System.out.print("Enter X of point 3:");
else
{
System.out.println("Your X3 value is not accpect for this program, please enter the value between 0 to 40.");
X3 = input.nextDouble();
}
if(Y3 >= minY || Y3 <= maxY)
System.out.print("Enter X of point 3:");
else
{
System.out.println("Your Y3 value is not accpect for this program, please enter the value between 0 to 40.");
Y3 = input.nextDouble();
}
POT = (Math.sqrt(Math.pow(X2-X1,2)) + (Math.pow(Y2-Y1,2)))+(Math.sqrt(Math.pow(X3-X1,2)) + (Math.pow(Y3-Y1,2)))+(Math.sqrt(Math.pow(X2-X3,2)) + (Math.pow(Y3-Y2,2)));
System.out.println("The perimeter of Triangle with Point1("+X1+","+Y1+"),point2("+X2+","+Y2+", and point3("+X3+","+Y3+")");
System.out.println("is"+POT+);
}
}
>javac Triangles.java
Triangles.java:80: 错误: 非法的表达式开始
System.out.println("is"+POT+);
^
1 个错误
>Exit code: 1
展开