import java.util.Scanner;
public class ScoreImprovementPercentage {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入上次考试成绩: ");
int oldScore = scanner.nextInt();
System.out.print("请输入本次考试成绩: ");
int newScore = scanner.nextInt();
double percentageIncrease = ((double) (newScore - oldScore) / oldScore) * 100;
System.out.printf("成绩提高了%.2f%%\n", percentageIncrease);
scanner.close();
}
Sign in to make a reply
对酒当歌
import java.util.Scanner;
public class ScoreImprovementPercentage {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入上次考试成绩: ");
int oldScore = scanner.nextInt();
System.out.print("请输入本次考试成绩: ");
int newScore = scanner.nextInt();
double percentageIncrease = ((double) (newScore - oldScore) / oldScore) * 100;
System.out.printf("成绩提高了%.2f%%\n", percentageIncrease);
scanner.close();
}
}