import java.util.Scanner;
public class Score {
public static void main(String[] atgs) {
Scanner scanner = new Scanner(System.in); // 创建Scanner对象
System.out.print("Input your second last score: "); // 打印提示
int score1 = scanner.nextInt(); // 读取一行输入并获取字符串
System.out.print("Input your last score: "); // 打印提示
int score2 = scanner.nextInt(); // 读取一行输入并获取整数
float percentage = (float)(score2 - score1) / score1 * 100;
System.out.println(percentage);
System.out.printf("Your current score is lower than the last time %.2f%%\n", percentage); // 格式化输出
}
Sign in to make a reply
用户6295308231
import java.util.Scanner;
public class Score {
public static void main(String[] atgs) {
Scanner scanner = new Scanner(System.in); // 创建Scanner对象
System.out.print("Input your second last score: "); // 打印提示
int score1 = scanner.nextInt(); // 读取一行输入并获取字符串
System.out.print("Input your last score: "); // 打印提示
int score2 = scanner.nextInt(); // 读取一行输入并获取整数
float percentage = (float)(score2 - score1) / score1 * 100;
System.out.println(percentage);
System.out.printf("Your current score is lower than the last time %.2f%%\n", percentage); // 格式化输出
}
}