try
Topic sourceScanner scanner = new Scanner(System.in);
System.out.print("Input your last score: ");
int last_score = scanner.nextInt();
System.out.print("Then input your this score:");
int now_score = scanner.nextInt();
double percentage_score = ((double)last_score - (double)now_score) / (double)last_score * 100;
if (percentage_score > 0) {
System.out.printf("Your grade has improved by %2.2f%% compared to last time", percentage_score);
} else if (percentage_score == 0) {
System.out.println("Your grades are the same as last time");
} else {
System.out.printf("Your grade is down %2.2f%% from last time", 0 - percentage_score);
}
- 1
PM-Rowlet