zoukankan      html  css  js  c++  java
  • c# 奖金计算

    /*

    输入利润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();

  • 相关阅读:
    数据加载存储和文件格式
    基本概率分布图的绘制
    pandas处理各类表格数据
    python时间处理
    matplotlib实现数据可视化
    sql学习笔记:表的运算
    sql杂记:一些坑和数据库恢复
    exists关键词和case表达式
    后台工具screen
    SQL函数小记
  • 原文地址:https://www.cnblogs.com/lovesy2413/p/4309529.html
Copyright © 2011-2022 走看看