- 最後登錄
- 2024-4-24
- 在線時間
- 9252 小時
- 註冊時間
- 2004-5-23
- 閱讀權限
- 200
- 精華
- 14
- UID
- 5
- 帖子
- 15722
- 積分
- 28040 點
- 潛水值
- 400319 米
| - // Exercise 3.1
- import javax.swing.*;
- public class sale_amount {
-
- static String input_goal_st;
- static int input_goal_int;
- static double base_salary = 5000;
- static double rate_1 = 8;
- static double rate_2 = 10;
- static double rate_3 = 12;
- static double limit_high_1 = 5000;
- static double limit_high_2 = 10000;
- static double limit_high_3 = 10000.01;
- static double limit_low_1 = 0.01;
- static double limit_low_2 = 5000;
- static double limit_low_3 = 10000;
- static String range_1 = "$0.01 - $5,000";
- static String range_2 = "$5,000.01 - $10,000";
- static String range_3 = "$10,000.01 and above";
- static double total_month = 12;
- static double mini_amount;
- static double sale_amount;
- static double sale_amount_final;
- static String x;
- static double y;
- static double z;
- static double w;
- static int i;
-
- public static void main(String[] args) {
-
- input_goal_st = JOptionPane.showInputDialog(null, "Input your targe commission of this year", "Calculation of commission",
- JOptionPane.QUESTION_MESSAGE);
-
- input_goal_int = Integer.parseInt(input_goal_st);
-
- for(i = 1; i <= 3; i++) {
-
- switch(i) {
- case 1 : x = range_1; y = limit_high_1; z = rate_1; w = limit_low_1;
- break;
- case 2 : x = range_2; y = limit_high_2; z = rate_2; w = limit_low_2;
- break;
- case 3 : x = range_3; y = limit_high_3; z = rate_3; w = limit_low_3;
- break;
- }
-
- mini_amount = (w * total_month);
- sale_amount = (base_salary) + (y * (z / 100) * total_month);
-
- if (sale_amount >= input_goal_int) {
- sale_amount_final = (input_goal_int - base_salary) * (100 / z);
- if ( sale_amount_final >= mini_amount) {
- System.out.println("The sale amount to meet your goal is " + sale_amount_final + "\nCommission rate is " + z + "\nSales amount range is " + x);
- JOptionPane.showMessageDialog(null, "The sale amount to meet your goal is " + sale_amount_final + "\nCommission rate is " + z + "\nSales amount range is " + x, "The information of the calculation", JOptionPane.INFORMATION_MESSAGE);
- } else {
- continue;
- }
- } else if(i == 3) {
- sale_amount_final = (input_goal_int - base_salary) * (100 / rate_3);
- if ( sale_amount_final >= mini_amount) {
- System.out.println("The sale amount to meet your goal is " + sale_amount_final + "\nCommission rate is " + z + "\nSales amount range is " + x);
- JOptionPane.showMessageDialog(null, "The sale amount to meet your goal is " + sale_amount_final + "\nCommission rate is " + z + "\nSales amount range is " + x, "The information of the calculation", JOptionPane.INFORMATION_MESSAGE);
- } else {
- continue;
- }
- } else {
- continue;
- }
- }
- }
- }
複製代碼 ... |
附件: 你需要登錄才可以下載或查看附件。沒有帳號?註冊 |