c# 獎金計算

來源:互聯網
上載者:User

標籤:

 

/*

輸入利潤I,輸出獎金(if和switch都寫了一個)

獎金計算:超過1000000的部分提1%;超過600000不足1000000的部分提1.5%;超過400000不足600000的部分提3%;超過200000不足400000的部分提5%;超過100000不足200000的部分提7.5%;不足100000的部分提10%

*/

double x, I;
x = 0;
Console.WriteLine("請輸入利潤I(元)");
I = Convert.ToDouble(Console.ReadLine());
if (I<=100000)
{

x=I*0.1;
}
else if (I<=200000)
{
x = (I-100000) * 0.075+100000*0.1;
}
else if (I <= 400000)
{
x = (I - 200000) * 0.05 +100000*0.075+ 100000 * 0.1;
}
else if (I <= 600000)
{
x = (I - 400000) * 0.03+200000*0.05 + 100000 * 0.075 + 100000 * 0.1;
}
else if (I <= 1000000)
{
x = (I - 600000) * 0.015 + 200000 * 0.03 + 200000 * 0.05 + 100000 * 0.075 + 100000 * 0.1;
}
else
{
x = (I - 1000000) *0.01+400000* 0.015 + 200000 * 0.03 + 200000 * 0.05 + 100000 * 0.075 + 100000 * 0.1;
}

Console.WriteLine("獎金是"+x+"元");
Console.ReadLine();
--------------------------------------------

double x,z,I;
int y;
int m1 = 100000, m2 = 200000, m3 = 400000, m4 = 600000, m5 = 1000000;
double n1 = 0.1, n2 = 0.075, n3 = 0.05, n4 = 0.03, n5 = 0.015, n6 = 0.01;

Console.WriteLine("請輸入利潤I(元)");
I = Convert.ToDouble(Console.ReadLine());
x = I / 100000;
y =(int)( I / 100000);
z = x - y;
switch (y)
{
case 0:
x = I * n1;
break;
case 1:
x = (I -m1) * n2 + m1 * n1;
break;
case 2:
x = (I -m2) * n3 + (m2-m1) * n2 + m1 * n1;
break;
case 3:
x = (I - m2) * n3 + (m2 - m1) * n2 + m1 * n1;
break;
case 4:
x = (I - m3) * n4 + (m3 -m2)* n3 + (m2-m1) * n2 + m1 * n1;
break;
case 5:
x = (I -m3) * n4 + (m3 - m2) * n3 + (m2 - m1) * n2 + m1 * n1;
break;
case 6:
x = (I - m4) * n5 + (m4-m3) * n4 + (m3 -m2)* n3 + (m2-m1) * n2 + m1 * n1;
break;
case 7:
x = (I - m4) * n5 + (m4 - m3) * n4 + (m3 - m2) * n3 + (m2 - m1) * n2 + m1 * n1;
break;
case 8:
x = (I - m4) * n5 + (m4 - m3) * n4 + (m3 - m2) * n3 + (m2 - m1) * n2 + m1 * n1;
break;
case 9:
x = (I - m4) * n5 + (m4 - m3) * n4 + (m3 - m2) * n3 + (m2 - m1) * n2 + m1 * n1;
break;
case 10:
x = (I - m5) * n6 + (m5 - m4) * n5 + (m4 - m3) * n4 + (m3 - m2) * n3 + (m2 - m1) * n2 + m1 * n1;
break;
default:
x = (I - m5) * n6 + (m5 - m4) * n5 + (m4 - m3) * n4 + (m3 - m2) * n3 + (m2 - m1) * n2 + m1 * n1;
break;
}

Console.WriteLine("獎金是" + x + "元");

Console.ReadKey();

c# 獎金計算

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.