一直提示Resource leak: 'scanner' is never closed,于是加了一句scanner.close();
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入上次考试成绩:");
int prev = scanner.nextInt();
System.out.print("请输入本次考试成绩:");
int score = scanner.nextInt();
scanner.close();
double percent = (double)(score-prev)/prev;
System.out.printf("成绩提高了%.2f%%",percent*100);
}
}
Google一下官网---Byron