TQC+ JAVA 308 電腦周邊費用總計
import java.util.Scanner;
public class JPA03 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
int total = 0, s = 0;
System.out.print("請輸入消費金額,或輸入-1結束:");
s=keyboard.nextInt();
do{
total+=s;
System.out.print("請輸入消費金額,或輸入-1結束:");
s=keyboard.nextInt();
}while(s!=-1);
System.out.println("電腦周邊總消費:"+total);
}
}
沒有留言:
張貼留言