[問題] 新手自學..請問'+='這個是做什麼的?
不好意思,新手自學很多地方不懂
有個問題解不開...所以來請問各位前輩
import java.util.Scanner;
public class Demo {
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
int score = 0 ;
int sum = 0 ;
int count = -1 ;
while(score != -1) {
count ++ ;
sum += score;
System.out.print("請輸入分數(-1結束):");
score = scanner.nextInt();
}
System.out.println("平均:" + (double) sum/count);
}
}
其中 'sum += score'和'count ++' 代表的意思為何呢?
目前小弟在自學..市面上的書也買了兩本來看,
發現都是以有編程過的角度出發去做教學..所以看的有點吃力。
還請各位前輩幫忙指導小弟...萬分感謝大家
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.161.80.11
※ 文章網址: https://www.ptt.cc/bbs/java/M.1431606287.A.CCF.html
推
05/14 21:01, , 1F
05/14 21:01, 1F
→
05/14 21:02, , 2F
05/14 21:02, 2F
→
05/14 21:06, , 3F
05/14 21:06, 3F
→
05/14 22:35, , 4F
05/14 22:35, 4F
推
05/14 22:47, , 5F
05/14 22:47, 5F
→
05/14 22:54, , 6F
05/14 22:54, 6F
推
05/14 23:04, , 7F
05/14 23:04, 7F
推
05/14 23:29, , 8F
05/14 23:29, 8F
→
05/14 23:29, , 9F
05/14 23:29, 9F
推
05/15 00:23, , 10F
05/15 00:23, 10F
→
05/15 00:46, , 11F
05/15 00:46, 11F
→
05/15 02:47, , 12F
05/15 02:47, 12F
→
05/15 02:48, , 13F
05/15 02:48, 13F
推
05/15 03:27, , 14F
05/15 03:27, 14F
→
05/15 09:58, , 15F
05/15 09:58, 15F
→
05/15 09:59, , 16F
05/15 09:59, 16F
推
05/15 10:11, , 17F
05/15 10:11, 17F
推
05/15 10:14, , 18F
05/15 10:14, 18F
推
05/15 10:45, , 19F
05/15 10:45, 19F
→
05/15 11:44, , 20F
05/15 11:44, 20F
推
05/15 18:15, , 21F
05/15 18:15, 21F
→
05/16 05:28, , 22F
05/16 05:28, 22F
→
05/17 16:12, , 23F
05/17 16:12, 23F
→
05/17 16:12, , 24F
05/17 16:12, 24F
→
05/17 16:13, , 25F
05/17 16:13, 25F
→
05/17 16:13, , 26F
05/17 16:13, 26F
java 近期熱門文章
PTT數位生活區 即時熱門文章