import java.util.Scanner;
public class Chen {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(true) {
System.out.print("你目前的平时分是:");
int peacetimeScore = sc.nextInt();
System.out.print("你的目标分数是:");
int soal = sc.nextInt();
if (peacetimeScore >= 0 && peacetimeScore <= 40) {
if (soal >= 0 && soal <= 100) {
int target = soal;
int realExamScore = target - peacetimeScore;
double examScore = realExamScore / 0.6;
if (examScore > 100) {
System.out.println("达不到这个分数");
} else {
System.out.printf("你期末需要考%.1f分才能达到目标分数\n", examScore);
}
} else {
System.out.println("错误;你的目标分应在0到100之间");
}
} else {
System.out.println("你的平时分应在0到40分之间");
}
}
}
}
import java.util.Scanner;//导入scanner类,用于从控制台读取用户输入
public class Chen {//定义一个名为FishTank的类,类是Java程序的基本组成部分
public static void main(String[] args) {//main方法是程序的入口,程序从这里开始执行
Scanner sc=new Scanner(System.in);//创建一个Scanner对象,sc用于读取用户输入
while(true) {
System.out.print("你目前的平时分是:");
int peacetimeScore = sc.nextInt();
System.out.print("你的目标分数是:");
int soal = sc.nextInt();
if (peacetimeScore >= 0 && peacetimeScore <= 40) {
if (soal >= 0 && soal <= 100) {
int target = soal;
int realExamScore = target - peacetimeScore;
double examScore = realExamScore / 0.6;
if (examScore > 100) {
System.out.println("达不到这个分数");
} else {
System.out.printf("你期末需要考%.1f分才能达到目标分数\n", examScore);
}
} else {
System.out.println("错误;你的目标分应在0到100之间");
}
} else {
System.out.println("你的平时分应在0到40分之间");
}
}
}
}