บทความล่าสุด

12 กันยายน 2555

โปรแกรมคำนวณหาเงินเดือน C#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CalculateMoney
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Please input Money : ");
            double salary = int.Parse(Console.ReadLine());
            double totalSS = 0, totalCP, totalBN;



            //เงื่อนไข หัก7 % ของเงินเดือนแต่ไม่เกิน750 บาท สำหรับประกันสังคม
            double socialsec = salary * 7 / 100;
            if (socialsec >= 750) socialsec = 750;
           totalSS = salary - socialsec;

            //เงื่อนไข หัก 4 % ของเงินเดือนสำหรับค่าสหกรณ์ออมทรัพย์
            double coop = salary * 4 / 100;
            totalCP = salary - coop;

            //เงื่อนไข โบนัส10% ของเงินเดือน
            double bonus = salary * 10 / 100; ;
            totalBN = bonus + salary;

            //เงื่อนไข รวมรายได้สุทธิทั้งปี
            double sum = (totalSS + totalCP + totalBN) * 12;

            //แสดงรายละเอียดสรุปเงินเดือน
            Console.WriteLine("\n\t- Result -\nSalary your is :{0} Baht",salary);
            Console.WriteLine("Social security : {0}\nTotal : {1}\n",socialsec,totalSS);
            Console.WriteLine("Cooperatives : {0}\nTotal : {1}\n", coop, totalCP);
            Console.WriteLine("Bonus : {0}\nTotal : {1}\n", bonus, totalBN);
            Console.WriteLine("Summation of salary : {0}\n", sum);
            ///
           
            Console.ReadLine();
        }
    }
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

แสดงความเห็นเกี่ยวกับบทความตรงนี้นะ ^^