if语句中的数学问题

吉安娜·卡鲁索(Gianna Caruso)

代码:

import java.util.Scanner; 
public class testqu {

        public static void main(String[] args) { 
          Scanner console = new Scanner(System.in); 
          System.out.println("Enter the length of the first side of the triangle"); 
          double a = console.nextInt(); 
          System.out.println("Enter the length of the second side of the triangle"); 
          double b = console.nextInt(); 
          System.out.println("Enter the length of the third side of the triangle"); 
          double c = console.nextInt(); 


          if ((a*a) + (b*b) = (c*c))
            System.out.println("The triangle is a right triangle!");



} 
}

任务:

在直角三角形中,最长边的长度的平方等于其他两条边的长度的平方之和。编写一个程序,提示用户输入三角形的三个边的长度,然后输出一条消息,指示三角形是否为直角三角形。不管输入3边的长度的顺序如何,程序都可以正常工作。

我的问题:代码无法编译,找到:变量,必填:值

另外:我不知道如何制作,因此即使没有按顺序给出边,程序也会知道三角形是否正确。请帮助,我是一位初学者,在处理此作业时遇到很多麻烦。

格特曼

使用比较运算符==比较值,而不是赋值运算符=赋值运算符不能将值分配给值,而只能分配给变量。改变

if ((a*a) + (b*b) = (c*c))

if ((a*a) + (b*b) == (c*c))

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章