Discuss / Java / 鸭蛋 == 成绩提高了-100%

鸭蛋 == 成绩提高了-100%

Topic source

及格先森

#1 Created at ... [Delete] [Delete and Lock User]

Scanner scanner = new Scanner(System.in);

System.out.print("上次成绩:");

int prev = scanner.nextInt();

System.out.print("本次成绩:");

int score = scanner.nextInt();

double percent = (double)(score - prev) / prev * 100;

if (percent < 0) {

    System.out.printf("成绩退步了%.2f%%", Math.abs(percent));

} else {

    System.out.printf("成绩提高了%.2f%%", percent);

}


  • 1

Reply