Discuss / Java / 嘿嘿,5年php转java

嘿嘿,5年php转java

Topic source
import java.util.Scanner;
public class Hello {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.print("Please enter the last grade: ");
		int lastGrade = scanner.nextInt();
		System.out.print("Please enter this grade: ");
		int thisGrade = scanner.nextInt();
		double promotion = 0.00;
		promotion = (double) (thisGrade-lastGrade)/lastGrade*100;
		if(thisGrade > lastGrade) {
			System.out.printf("恭喜,你本次成绩提升百分之:%.2f%%", promotion);
		}else {
			System.out.printf("再接再厉,你本次成绩并无提升,下降:%.2f%%", promotion);
		}
	}
}


  • 1

Reply