日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

UT源码_021

發(fā)布時間:2025/3/15 编程问答 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UT源码_021 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

設(shè)計傭金

commission方法是用來計算銷售傭金的需求,手機配件的銷售商,手機配件有耳機(headphone)、手機殼(Mobile phone shell)、手機貼膜(Cellphone screen protector)三個部件,每個部件單價為:耳機80元,手機殼10元,手機貼膜8元,每月月末向制造商報告銷量,制造商根據(jù)銷量給銷售商傭金。如果銷售額不足1000元按10%提取傭金,1000-1800元部分按15%提取傭金,超過1800元部分按20%提取傭金。

?程序要求:

1)先顯示“請分別輸入三種手機配件的銷售情況:”

2)不滿足條件,返回:“輸入數(shù)量不滿足要求”,返回重新輸入;

3)條件均滿足, 則返回傭金額。返回等待輸入。

??? float? commission (int headphone, int shell, int protector)

?

// ETestOne by:mtLin 2017.3.10 import java.util.Scanner;public class One {/** hp:耳機 80元 mpc:手機殼 10元 cpsp:手機貼膜 8元*/public static void main(String[] args) {String line;int hp = 0, mpc = 0, cpsp = 0;String[] input = null;float money = 0;@SuppressWarnings("resource")Scanner scanner = new Scanner(System.in);while (true) {System.out.println("請分別輸入三種手機配件的銷售情況:");line = scanner.nextLine();input = line.split(" ");if (Judge(input)) {// 判斷是否不小于0if ((hp = Integer.parseInt(input[0])) < 0) {System.out.println("輸入數(shù)量不滿足要求");continue;}if ((mpc = Integer.parseInt(input[1])) < 0) {System.out.println("輸入數(shù)量不滿足要求");continue;}if ((cpsp = Integer.parseInt(input[2])) < 0) {System.out.println("輸入數(shù)量不滿足要求");continue;}} else {System.out.println("輸入數(shù)量不滿足要求");continue;}money = commission(hp, mpc, cpsp);System.out.println("傭金金額:" + money);}}// 計算傭金private static float commission(int hp, int mpc, int cpsp) {float commission = 0;int total = hp * 80 + mpc * 10 + cpsp * 8;if (total < 1000) {commission = (float) (total * 0.1);} else if (total <= 1800) {commission = (float) (1000 * 0.1 + (total - 1000) * 0.15);} else {commission = (float) (1000 * 0.1 + 800 * 0.15 + (total - 1800) * 0.2);}return commission;}// 判斷用戶輸入的是不是三個整數(shù)private static boolean Judge(String[] input) {String number = "0123456789";// 判斷輸入的是不是三個字符串if (input.length != 3) {return false;}// 判斷三個字符串是不是純數(shù)字且不含小數(shù)點for (int i = 0; i < 3; i++) {for (int j = 0; j < input[i].length(); j++) {if ("+-".indexOf(input[i].charAt(0)) == 1) {continue;}if (number.indexOf(input[i].charAt(j)) == -1) {return false;}}}return true;} }

?

轉(zhuǎn)載于:https://www.cnblogs.com/mtLin/p/6531231.html

總結(jié)

以上是生活随笔為你收集整理的UT源码_021的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。