調(diào)用輸入指令Scanner
/**
* 根據(jù)用戶輸入月薪及一年多少薪計(jì)算年薪,按88退出計(jì)算器,按66重新計(jì)算
*/
import java.util.Scanner;
//調(diào)用Scanner 實(shí)現(xiàn)用戶輸入
public class SalaryCalculator {
? ?public static void main(String[] args) {
? ? ? ?Scanner s = new Scanner(System.in);
? ? ? ?//System.in 輸入
? ? ? ?System.out.println("年薪計(jì)算\t輸入88退出計(jì)算器\t輸入66重新計(jì)算");
? ? ? ?while (true){
? ? ? ? ? ?System.out.println("請輸入您的月薪:");
? ? ? ? ? ?int monthSalary = s.nextInt();
? ? ? ? ? ?//s.nextInt()將輸入數(shù)據(jù)轉(zhuǎn)化為int
? ? ? ? ? ?if (monthSalary == 88)break;
? ? ? ? ? ?if (monthSalary == 66)continue;
? ? ? ? ? ?System.out.println("請輸入薪數(shù):");
? ? ? ? ? ?int months = s.nextInt();
? ? ? ? ? ?if (months == 88)break;
? ? ? ? ? ?if (months == 66)continue;
? ? ? ? ? ?System.out.println("您的年薪為: "+monthSalary*months);
? ? ? ? ? ?System.out.println("感謝使用!\n輸入88退出計(jì)算器\t輸入66重新計(jì)算");
? ? ? ?}
? ? ? ?System.out.println("計(jì)算結(jié)束");
? ?}
}