请在代码中使用 break或 continue语句

请在代码中使用 break或 continue语句
从键盘上输入若干个同学的成绩,直到-1为止,输出平均成
绩。

import java.util.Scanner;
public class Test{
  public static void main(String [] args){
      Scanner input = new Scanner(System.in);
      float sum = 0;
      int num = 0;
      int n = 0;
      while(true){
            num = input.nextInt();
            if(num == -1){
                break;
            }else{
              sum += num;
              n++;
              continue;
          }
      }
      System.out.println("平均分:"+sum/n);
  }

}

public class mainDemo {
    public static void main(String [] args) {
         Scanner sc = new Scanner(System.in);//创建一个scanner类的对象
        int scoreall=0;
        int score = 0;
        int n=0;
        while(1)
        {
              score =  sc.nextInt();
              if(score == -1)
                  break;
              else
              {
                  scoreall+=score;
                  n++;
              }
        }
        System.out.println(scoreall/n);
    }
}