年薪计算器

 1 /**
 2  * 薪水计算器
 3  * (1)通过键盘输入用户的月薪,每年是几个月薪水。
 4  * (2)输出用户的年薪
 5  * (3)输出一行字“如果年薪超过10万,恭喜你超越90%的国人”,“如果年薪超过20万,恭喜你超越98%的国人”。
 6  * (4)直到键盘输入数字88,则退出程序(使用break退出循环)
 7  * (5)键盘输入66,直接显示“继续计算下一个薪资”,然后算下一个用户的年薪。
 8  */
 9 import java.util.Scanner;
10 public class SalaryCalculator{
11 
12     public static void main(String[] args) {
13         Scanner s = new Scanner(System.in);
14         System.out.println("***********我的薪水计算器***********");
15         System.out.println("1.输入88,退出程序\n2.输入66,计算下一个年薪");
16 
17         while(true){
18             System.out.println("请输入月薪:");
19             int monthSalary = s.nextInt();
20             System.out.println("请输入一年几个月薪资:");
21             int months = s.nextInt();
22             int yearSalary = monthSalary*months;  //年薪
23 
24             System.out.println("年薪是:"+yearSalary);
25             if(yearSalary>=200000){
26                 System.out.println("恭喜你超越98%的国人");
27             }else if(yearSalary>=100000){
28                 System.out.println("恭喜你超越90%的国人");
29             }
30 
31             System.out.println("输入88,退出系统;输入66,继续计算。");
32             int comm = s.nextInt();
33             if(comm==88){
34                 System.out.println("系统退出!");
35                 break;
36             }
37             if(comm==66) {
38                 System.out.println("继续计算下一个薪资");
39                 continue;
40             }
41 
42         }
43 
44     }
45 
46 }

 

posted @ 2022-04-02 15:31  final如风  阅读(654)  评论(0)    收藏  举报