您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇文章为大家展示了使用.NET编写一个工资管理系统,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
具体内容如下
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace gongzi { class Program { static bool flag = true; //工人数 const int NUM = 3; //定义二维数组 static string[,] gong = new string[NUM, 5]; static void Main(string[] args) { Console.Title = "工资管理系统"; jiemian(); //菜单界面 login(); //登录界面 while (flag) { caidan(); //菜单界面 } } static void jiemian() { Console.Clear(); Console.WriteLine("------工资管理系统------"); Console.WriteLine("-----@lijia---2018-4-4-----------"); Console.ReadKey(); } static void login() //登录界面 { Console.WriteLine("请输入用户名:"); String username = Console.ReadLine(); Console.WriteLine("请输入密码:"); String password = Console.ReadLine(); if (username == "lijia" && password == "123456") { flag = true;//进入菜单界面 } else { Console.WriteLine("对不起,你输入的用户名或者密码错误!请重新输入!"); flag = false; } } static void caidan() { Console.Clear(); Console.WriteLine("工资管理系统"); Console.WriteLine("1.工资录入"); Console.WriteLine("2.工资查询"); Console.WriteLine("3.工资修改"); Console.WriteLine("4.工资统计"); Console.WriteLine("0.退出系统"); Console.WriteLine("请输入0-3数字:"); String choice = Console.ReadLine(); switch (choice) { case "1": Console.WriteLine("工资录入"); Inputgongzi(gong,NUM); Console.ReadKey(); break; case "2": Console.WriteLine("工资查询"); Outputgongzi(gong, NUM); Console.ReadKey(); break; case "3": Console.WriteLine("请输入你需要选择的哪种工资的修改:(1基本工资2奖金)"); string temp = string.Empty; int t = Convert.ToInt32(Console.ReadLine()); switch (t) { case 1: Console.WriteLine("输入您要修改基本工资在二维数组中所在行数(0-2):"); int t1 = Convert.ToInt32(Console.ReadLine()); temp = gong[t1, 2]; gong[t1, 2] = Console.ReadLine(); sfgz(); break; case 2: Console.WriteLine("输入您要修改的奖金在二维数组中所在行数(0-2):"); int t2 = Convert.ToInt32(Console.ReadLine()); temp = gong[t2, 3]; gong[t2, 3] = Console.ReadLine(); sfgz(); break; } break; case "4": double a = Convert.ToDouble(gong[0, 4]); double b = Convert.ToDouble(gong[1, 4]); double c = Convert.ToDouble(gong[2, 4]); if (a > b) { if (a > c) { Console.WriteLine("最高工资:{0}", a); if (b > c) { Console.WriteLine("最低工资:{0}", c); } else { Console.WriteLine("最低工资:{0}", b); } } else { Console.WriteLine("最高工资:{0}", c); } } else {//a<b if (b > c) { Console.WriteLine("最高工资:{0}", b); if (a > c) { Console.WriteLine("最低工资:{0}", c); } else { Console.WriteLine("最低工资:{0}", a); } } else//b<c { Console.WriteLine("最高工资:{0}", c); Console.WriteLine("最低工资:{0}", a); } } double pjzhi = (a + b + c) / 3; Console.WriteLine("工资平均值:{0}", pjzhi); Console.ReadKey(); break; case "0": flag = false; break; } } static void Inputgongzi(string[,] gong,int NUM) { string yuangong = string.Empty; string[] tmp; for (int i = 0; i < NUM; i++) { Console.WriteLine("请输入第{0}个工人的工号、姓名、基本工资、奖金(以空格分割):", i + 1); yuangong = Console.ReadLine(); //分割工人信息 tmp = yuangong.Split(' '); for (int j = 0; j < tmp.Length; j++) { gong[i, j] = tmp[j]; } //计算实发工资 double sodeshui = 0; double sfgz; double jbgz = Convert.ToDouble(gong[i, 2]); double jj = Convert.ToDouble(gong[i, 3]); if ((jbgz + jj) < 5000) { sfgz = jbgz + jj - sodeshui; gong[i, 4] = Convert.ToString(sfgz); } else if ((jbgz + jj) < 8000) { sodeshui = jbgz * 0.03; } else if ((jbgz + jj) < 20000) { sodeshui = 3000 * 0.03 + (jbgz - 8000) * 0.15; } else if ((jbgz + jj) > 20000) { sodeshui = 3000 * 0.03 + 2000 * 0.15 + (jbgz - 20000) * 0.25; } //计算实发工资 sfgz = jbgz + jj - sodeshui; gong[i, 4] = Convert.ToString(sfgz); } } static void sfgz() { double sodeshui = 0; double sfgz; int i = 0; double jbgz = Convert.ToDouble(gong[i, 2]); double jiangjin = Convert.ToDouble(gong[i, 3]); if ((jbgz + jiangjin) < 5000) { sfgz = jbgz + jiangjin - sodeshui; gong[i, 4] = Convert.ToString(sfgz); } else if ((jbgz + jiangjin) < 8000) { sodeshui = jbgz * 0.03; } else if ((jbgz + jiangjin) < 20000) { sodeshui = 3000 * 0.03 + (jbgz - 8000) * 0.15; } else if ((jbgz + jiangjin) > 20000) { sodeshui = 3000 * 0.03 + 2000 * 0.15 + (jbgz - 20000) * 0.25; } //计算实发工资 sfgz = jbgz + jiangjin - sodeshui; gong[i, 4] = Convert.ToString(sfgz); } static void Outputgongzi(string[,] gong, int NUM) { Console.WriteLine("-----------工人工资单-------------"); Console.WriteLine("|----------------------------------|"); Console.WriteLine("|工 号|姓 名|基本工资|奖 金|实发工资|"); Console.WriteLine("-----------------------------------|"); for (int i = 0; i < NUM; i++) { Console.WriteLine("|{0,5}|{1,8}|{2,8:f2}|{3,8:f2}|{4:8,f2}|", gong[i, 0], gong[i, 1], gong[i, 2], gong[i, 3], gong[i, 4]); Console.WriteLine("|---------------------------------------------|"); } } } }
上述内容就是使用.NET编写一个工资管理系统,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。