import java.util.Scanner;
public class JPA304 {
public static void main(String[] args) {
int total = 0;
int s = 0;
int count = 0;
double average;
Scanner input = new Scanner(System.in);
do{
total+=s;
count++;
System.out.print("Please enter meal dollars or enter -1 to stop: ");
s=input.nextInt();
}while(s!=-1);
average=total/(double)(count-1);
System.out.println("餐點總費用:"+total);
System.out.printf(" %d 道餐點平均費用為: %.2f %n",count-1,average);
}
}
沒有留言:
張貼留言