訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容
import java.io.*; public class ex5_10 { public static void main(String[] args) throws IOException { int time = 0, sum = 0, total = 0, total2 = 0, total3 = 0, total4 = 0; InputStreamReader in = new InputStreamReader(System.in); BufferedReader buf = new BufferedReader(in); System.out.print("請輸入整月的工作時數:"); time = Integer.parseInt(buf.readLine()); System.out.print("請輸入固定時薪:"); sum = Integer.parseInt(buf.readLine()); if (sum >= 121) { total = 60 * sum; total2 = (int) (sum * 1.33) * 60; total3 = (int) (sum * 1.66) * (time - 120); total4 = total + total2 + total3; System.out.println("薪水為:" + total4); } else if (sum >= 61) { total = 60 * sum; total2 = (int) (sum * 1.33) * (time - 60); total3 = total + total2; System.out.println("薪水為:" + total3); } else { total = time * sum; System.out.println("薪水為:" + total); } } }