方法声明无效,需要返回类型,请帮新手看看哪里不行

【编程】 方法声明无效,需要返回类型,请帮新手看看哪里不行

--------------------------------------------

傻大方资讯为您精选的网友回复(供您参考):

[手机]import java.util.Scanner;public class BMITest{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); Counter cou = new Counter(); System.out.println(cou.getbmi()); } }class Counter{ public bmi(double weight,double height){ scan.weight = nextDouble(System.in); scan.height = nextDouble(System.in); double bmi=weight/Math.pow(height,2); } public double getbmi(){ return bmi; }public void man(){ if( bmi < 20 ) System.out.println("过轻"); if( bmi > 20 && bmi<= 25 ) System.out.println("适中"); if( bmi>25 && bmi<=30 ) System.out.println("过重"); if( bmi>30 && bmi<=35 ) System.out.println("肥胖"); if( bmi>35 ) System.out.println("非常肥胖"); } public void woman(){ if( bmi <19 ) System.out.println("过轻"); if( bmi > 19 && bmi<= 24 ) System.out.println("适中"); if( bmi>24 && bmi<=29 ) System.out.println("过重"); if( bmi>29 && bmi<=34 ) System.out.println("肥胖"); if( bmi>34 ) System.out.println("非常肥胖");}}

--------------------------------------------