- 输入输出
请帮小明同学设计一个程序,输入上次考试成绩(int)和本次考试成绩(int),然后输出成绩提高的百分比,保留两位小数位(例如,21.75%)
1 import java.util.Scanner; 2 public class Main { 3 4 public static void main(String[] args) { 5 6 Scanner scanner = new Scanner(System.in); 7 System.out.println("请输入上一次的成绩:"); 8 float score1 = scanner.nextFloat(); 9 System.out.println("请输入本次成绩:"); 10 float score2 = scanner.nextFloat(); 11 12 float score = (score2 - score1)/score1*100; 13 14 System.out.printf("成绩提高了:%.2f%%",score); 15 } 16 17 }