switch-case計算銷售提成慕姜100w<=利潤<110w部分提:1%?60w<=利潤<100w部分提:1.5%40w<=利潤<60w部分提:3%20w<=利潤<40w部分提:5%10w<=利潤<20w部分提:7.5%利潤<10w部分提:10%假定利潤額不會超過110w(110w以上部分不考慮)以下是我這個小白白寫的,錯的,只能輸出第一個switch,其他數值可以運行但什么都不輸出,求大神詳解( ▼-▼ )using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ticheng{? ? class Program? ? {? ? ? ? static void Main(string[] args)? ? ? ? {? ? ? ? ? ? double bonus = 1000000;? ? ? ? ? ? double one=0.01;? ? ? ? ? ? double two=0.015;? ? ? ? ? ? double three=0.03;? ? ? ? ? ? double four=0.05;? ? ? ? ? ? double five=0.075;? ? ? ? ? ? double six=0.1;? ? ? ? ? ? char times = '*';? ? ? ? ? ? if (bonus >= 1000000 && bonus <= 1100000)? ? ? ? ? ? {? ? ? ? ? ? ? ? switch (times)? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? case '*': Console.Write(bonus * one); break;? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ?if(bonus>=600000&&bonus<1000000)? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? switch(times)? ? ? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? ? ? case '*': Console.Write(bonus * two); break;? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? if (bonus >= 400000 && bonus < 600000)? ? ? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? ? ? switch (times)? ? ? ? ? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? ? ? ? ? case '*': Console.Write(bonus * three); break; ?? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? if (bonus >= 200000 && bonus < 400000)? ? ? ? ? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? ? ? ? ? switch (times)? ? ? ? ? ? ? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case '*': Console.Write(bonus * four); break;?? ? ? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? ? ? if (bonus >= 100000 && bonus < 200000)? ? ? ? ? ? ? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? switch (times)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case '*': Console.Write(bonus * five); break;?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (bonus < 100000)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? switch (times)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case '*': Console.Write(bonus * six); break;?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (bonus > 1100000)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("老板讓給你!");? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? }? ? ? ? ? ? }? ? ? ? }? ? }}
1 回答
已采納

望遠
TA貢獻1017條經驗 獲得超1032個贊
?if?(bonus?>=?1000000?&&?bonus?<=?1100000) ???{ ????switch?(times) ??{ ???case?'*':?Console.Write(bonus?*?one);?break; ???} ??//這里應該有一個}上一種情況結束,下同,其實就是括號的問題 ??if(bonus>=600000&&bonus<1000000) ????{ ?????switch(times) ????{ ?????case?'*':?Console.Write(bonus?*?two);?break; ?????}
你這里雖然用了switch但是都是無用功,而是用if..else if...if來實現的
- 1 回答
- 0 關注
- 1605 瀏覽
添加回答
舉報
0/150
提交
取消