程序有问题,倒数第三行,然后加了while(reader.hasNextDouble()){ 加try catch显示没有main

程序有问题,倒数第三行,然后加了while(reader.hasNextDouble()){ 加try catch显示没有main

问题描述:

package tt1;

import java.util.*;

public class work2 {

public static void main(String[]args)

{Scanner reader=new Scanner(System.in) ;

double t=1;

int a=0;

while(reader.hasNextDouble()){

double x=reader.nextDouble();

a=a+1;

t=t*x;

}

Ѕуѕtеm.оut.рrіntf("%d个整数的乘积为%f\n",a,t);

}

}

这样子看看还有没有

import java.util. * ;
public class work2 {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System. in );
        double t = 1;
        int a = 0;
        while (reader.hasNextDouble()) {
            double x = reader.nextDouble();
            a = a + 1;
            t = t * x;
        }
        Ѕуѕtеm.оut.рrіntf("%d个整数的乘积为%f\n", a, t);
    }
}

如还不明白,欢迎交流。

img


你自己的代码里这里也是粘在一起的么
public static void main(String[] args) 中间有空格