主线程异常怎么解决啊.

package com.sy;

import java.util.Scanner;

public class cfcs {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    while (true){
    Scanner sc = new Scanner (System.in);
    
    System.out.println("请输入星期数: ");
    int week = sc. nextInt();
    
    if (week == 1) {
        System.out.println("跑步");
    }
    if (week == 2) {
        System.out.println("游泳");
    }
    if (week == 3) {
        System.out.println("慢走");
    }
    if (week == 4) {
        System.out.println("动感单车");
    }
    if (week == 5) {
        System.out.println("拳击");
    }
    if (week == 6) {
        System.out.println("爬山");
    }
    if (week == 7) {
        System.out.println("好好吃一顿");
        break; 
    }
    sc.close();
}
}

}
新手有没有人知道怎么解决.

img

public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner (System.in);
        while (true){
            System.out.println("请输入星期数: ");
            int week = sc. nextInt();
            if (week == 1) {
                System.out.println("跑步");

            }
            if (week == 2) {
                System.out.println("游泳");

            }
            if (week == 3) {
                System.out.println("慢走");

            }
            if (week == 4) {
                System.out.println("动感单车");

            }
            if (week == 5) {
                System.out.println("拳击");

            }
            if (week == 6) {
                System.out.println("爬山");

            }
            if (week == 7) {
                System.out.println("好好吃一顿");
                break;
            }
        }
    }

可以的话能采纳并关注吗