Scanner scanner = new Scanner(System.in); // 创建Scanner对象System.out.print("上次考试成绩"); // 打印提示int score = Integer.parseInt(scanner.nextLine()); // 读取一行输入并获取字符串System.out.print("本次考试成绩 "); // 打印提示int score1 = scanner.nextInt(); // 读取一行输入并获取整数double percentage = ((double)score1 - score)/score*100;System.out.printf("成绩提高了,%.2f%%", percentage); // 格式化输出
Sign in to make a reply
姜楠