package xiafly;
import java.util.Scanner;
public class Sarly {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.printf("\t年薪计算器\n");
int Sarly = 0, months = 0;
double yearSarly;
while (true) {
System.out.printf("\n\t请属于月薪:");
Sarly = s.nextInt();
System.out.printf("\t请属于月份数:");
months = s.nextInt();
yearSarly = Sarly * months;
System.out.printf("\t您的年薪为:" + yearSarly + "元");
if (100000 < yearSarly && yearSarly < 200000) {
System.out.println("\n\t恭喜您的年收入超过%90的人");
}
if (yearSarly >= 200000) {
System.out.println("\n\t恭喜您的年收入超过%98的人");
}
System.out.println("\n\t命令:exit(直接退出程序)\t命令:next(计算下一用户年薪)");
s.nextLine();
System.out.printf("\t请输入命令:");
String conand = s.nextLine();
if ("exit".equals(conand)) {
System.out.printf("\n\t退出程序");
break;
}
if ("next".equals(conand)) {
System.out.printf("\n\t请输入新用户数据:");
continue;
}
}
}
}
运行示例:
年薪计算器
请属于月薪:6000
请属于月份数:13
您的年薪为:78000.0元
命令:exit(直接退出程序) 命令:next(计算下一用户年薪)
请输入命令:exit
退出程序
Process finished with exit code 0