搜索
熱搜: 活動 交友 discuz
查看: 1299|回復: 0
打印 上一主題 下一主題

[教學] IVE Exercise 3.1 Sample

[複製鏈接]
跳轉到指定樓層
1#
發表於 2007-7-27 21:13:06 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
// 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;
      }
    }
  }
}
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

本論壇為非營利之網路平台,所有文章內容均為網友自行發表,不代表論壇立場!若涉及侵權、違法等情事,請告知版主處理。


Page Rank Check

廣告刊登  |   交換連結  |   贊助我們  |   服務條款  |   免責聲明  |   客服中心  |   中央分站

手機版|中央論壇

GMT+8, 2024-5-15 22:02 , Processed in 0.016710 second(s), 16 queries .

Powered by Discuz!

© 2005-2015 Copyrights. Set by YIDAS

快速回復 返回頂部 返回列表