close

2007.4.13

直接複製我在bbs上打的題目內容XD:
手動由鍵盤輸入
基本薪資
津貼
時薪

結果:
(1)需先選擇專任員工或工讀生(用switch)
(2)如果是專任員工(full time)
薪水 = 基本薪資+津貼
(3)如果是工讀生(part time)

需再輸入工作時數

當 時數而當 50小時而當 100小時最後當 時數>150小時之後 薪水 = 時數*時薪*0.4

最後結果就是輸出所獲得的薪資


雖然說應該非必要,不過還是藉機練習了一下四捨五入到整數位XD

-------------------------------------------------------------------
import java.io.*;

public class homework9458050_3{
public static void main(String[] alio)
throws IOException{

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("請輸入基本薪資(若是工讀生請輸入0):");
int a = Integer.parseInt(br.readLine());
System.out.println("請輸入津貼(若是工讀生請輸入0):");
int b = Integer.parseInt(br.readLine());
System.out.println("請輸入時薪(可含小數):");
double c = Double.parseDouble(br.readLine());
double money;

System.out.println("請問你是:1.專任員工,2.工讀生:");
System.out.print("→");
int d = Integer.parseInt(br.readLine());
switch(d){
case 1:
money = a + b;
System.out.println("您的薪資為:"+(int)Math.floor(money+0.5)+"元");
break;
case 2:
System.out.println("請輸入工作時數(可含小數):");
double f = Double.parseDouble(br.readLine());
if(f money = c * f;
else if(f money = c * f * 0.8;
else if(f money = c * f * 0.6;
else
money = c * f * 0.4;
System.out.println("您的薪資為:"+(int)Math.floor(money+0.5)+"元");

break;
default:
System.out.println("輸入格式錯誤,程式即將關閉。");

}
}
}
------------------------------------------------------------------------


全站熱搜
創作者介紹
創作者 steven70101 的頭像
steven70101

老人家的舊書房

steven70101 發表在 痞客邦 留言(0) 人氣()