Discuss / Java / 交作业

交作业

Topic source

-不要回答

#1 Created at ... [Delete] [Delete and Lock User]
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入姓名:");
		String name = scanner.nextLine();
		System.out.println("请输入第一次考试成绩:");
		double score1 = scanner.nextInt();
		System.out.println("请输入第二次考试成绩:");
		double score2 = scanner.nextInt();
		if (score2==score1) {
			System.out.printf("成绩没有变化");
		}
		else if(score2>score1){
			System.out.printf("成绩下降了%.3f%%",100*(score2-score1)/score1);		
		}
		else{
			System.out.printf("成绩下降了%.3f%%",100*(score1-score2)/score1);
		}	
	}
}
	

  • 1

Reply