import java.util.Scanner;
public class Test{ public static void main(String args[]) { Scanner scanner = new Scanner(System.in); System.out.print("上次考试成绩: "); int last = scanner.nextInt(); System.out.print("本次考试成绩: "); int now = scanner.nextInt(); double percent = (double) (now > last ? (now - last) : (last - now)) / last * 100; System.out.printf("本次考试" + ((now > last) ? "提升" : "降低") + "%.2f%%", percent); } }
Sign in to make a reply
Cn4_F
import java.util.Scanner;
public class Test{
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
System.out.print("上次考试成绩: ");
int last = scanner.nextInt();
System.out.print("本次考试成绩: ");
int now = scanner.nextInt();
double percent = (double) (now > last ? (now - last) : (last - now)) / last * 100;
System.out.printf("本次考试" + ((now > last) ? "提升" : "降低") + "%.2f%%", percent);
}
}