求和
package aila2;
import java.util.Scanner;
public class sum {
public static void main(String[] args)
{
double sum=0;
Scanner input = new Scanner(System.in);
System.out.print("输入几个数求和: ");
double data = input.nextDouble();
while(data != 0)
{
sum += data;
System.out.print("输入一个数,如果输入是0,则程序结束。 ");
data = input.nextDouble();
}
System.out.println("最后结果为 :" + sum);
}