Created
May 24, 2017 11:41
-
-
Save peter279k/c74680f2486b3e6319cd000c42976013 to your computer and use it in GitHub Desktop.
TQC+ JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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