Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created May 24, 2017 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter279k/c74680f2486b3e6319cd000c42976013 to your computer and use it in GitHub Desktop.
Save peter279k/c74680f2486b3e6319cd000c42976013 to your computer and use it in GitHub Desktop.
TQC+ JAVA
import java.util.Scanner;
public class JPA03 {
static Scanner keyboard = new Scanner(System.in);
static int i = -1;
public static void main(String[] args) {
int total = 0, s = 0;
System.out.print("請輸入消費金額,或輸入-1結束:");
do {
s = keyboard.nextInt();
if(s == -1) {
break;
}
total += s;
System.out.print("請輸入消費金額,或輸入-1結束:");
} while(true);
System.out.println("電腦週邊總消費:" + total);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment