計算員工薪水,底薪 : 25000,100000 以上 獎金 5%,300000 以上 獎金 7%,500000 以上 獎金 10%。
執行結果,如下。
程式碼,如下。
import java.util.Scanner;
public class EX2_6 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.print("\n請輸入業績 》》》》》 ");
double accomplishment = stdIn.nextDouble();
double salary = 25000;
double prize = 0;
if (accomplishment >= 100000 && accomplishment < 300000) {
prize = accomplishment * 0.05;
} else if (accomplishment >= 300000 && accomplishment < 500000) {
prize = accomplishment * 0.07;
} else if (accomplishment >= 500000) {
prize = accomplishment * 0.1;
}
System.out.println("本月薪資 : " + (salary + prize) + "(底薪:" + salary
+ " 獎金:" + prize + ")");
}
}
2012年4月4日 星期三
訂閱:
張貼留言 (Atom)
No Response to "練習題 2_6:計算薪水"
張貼留言