gpt4 book ai didi

java - ./ucgenAlanı.java :23: error: missing return statement }

转载 作者:行者123 更新时间:2023-12-01 12:22:09 25 4
gpt4 key购买 nike

我正在尝试获取三角形的区域。但我有一个错误 ./ucgenAlanı.java:23: 错误: 缺少返回语句}你能帮我吗?

import java.util.Scanner;

public class ucgenAlanı {

private double a1,a2,a3;

public void setDimensions( double newa1,double newa2,double newa3 ) {
a1 = newa1;
a2 = newa2;
a3 = newa3;
}

public double readInput() {
Scanner klavye = new Scanner(System.in);
System.out.println(" kenarları giriniz : ");
a1=klavye.nextDouble();
a2=klavye.nextDouble();
a3=klavye.nextDouble();
}

public double getArea() {
double s= (a1 + a2 + a3) / 2;
double area = Math.sqrt( s*(s-a1)*(s-a2)*(s-a3) );
System.out.println( area + "ucgenin alanı" );
return area;
}
}

最佳答案

readInput 方法不返回 double 值。

查看您的代码,将方法返回类型更改为 void 以解决问题

关于java - ./ucgenAlanı.java :23: error: missing return statement },我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26597504/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com