首页 新闻 会员 周边 捐助

毕业 设计题。 大佬 帮忙的重重有赏。 急用 ,谢谢各位大佬了

0
悬赏园豆:100 [待解决问题]

创建一个具有1000行的数据文件。文件中的每行包含一个教职员工的姓,名,级别以及薪水。第i行的教职员工的姓和名为FirstNamei 和LastNamei。级别随机产生为assistant(助理),associate(副)以及full(正)。薪水为随机产生的数字,并且小数点后保留俩位数字。对于助理教授而言,薪水应该在50000到80000的范围内,对于副教授为60000到110000,对于正教授为75000到130000.将生成的数据保存文件为salary.txt。 下面是一些示例数据:
FirstNameI LastNamel assistant
60055.95
FirstName2 LastName2 associate
81112.45

FirstName1000 LastName1000 full
92255.21

大数据的分析
编写一个程序,分别显示salar.txt文件中助理教授,副教授,正教授各个类别的总薪水,各类别的平均薪水以及各类别的职工数。

用java语言写。

刀妹是信仰的主页 刀妹是信仰 | 初学一级 | 园豆:102
提问于:2020-12-20 16:26
< >
分享
所有回答(7)
0

嗯?最基本的东西?哪儿的毕业设计?

顾晓北 | 园豆:10898 (专家六级) | 2020-12-20 17:30
0

这个是最基本的东西,建议学一下python的pandas库,很容易感觉

没尾巴的刺刺鱼 | 园豆:204 (菜鸟二级) | 2020-12-20 17:55

人家都说了用java,还py个锤子,

支持(0) 反对(0) 橙子Cjw | 园豆:109 (初学一级) | 2020-12-21 09:01

Ծ‸Ծ

支持(0) 反对(0) 没尾巴的刺刺鱼 | 园豆:204 (菜鸟二级) | 2020-12-21 09:25
0

对这个薪水比较感兴趣。
为啥搞txt?
效果

附上c#代码:

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

namespace cnblog_132765
{
    class Program
    {
        readonly static SalaryBand assistant = new() { Name = "assistant", Floor = 50000, Upper = 80000 };
        readonly static SalaryBand associate = new() { Name = "associate", Floor = 60000, Upper = 110000 };
        readonly static SalaryBand full = new() { Name = "full", Floor = 75000, Upper = 130000 };
        readonly static SalaryBand[] salaryBands = new SalaryBand[3] { assistant, associate, full };
        static void Main(string[] args)
        {
            var file = CreateData();

            using var fileStream = new FileStream(file, FileMode.Open);
            using var reader = new StreamReader(fileStream, Encoding.Default);
            List<Teacher> teachers = new();
            var line = string.Empty;
            var lineSalary = string.Empty;
            string[] t = new string[3];
            while (!string.IsNullOrWhiteSpace(line = reader.ReadLine()))
            {
                lineSalary = reader.ReadLine();
                t = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                teachers.Add(new Teacher(t[0], t[2], double.Parse(lineSalary)));
            }
            // 统计
            var group = teachers.GroupBy(t => t.Type).Select(g => new
            {
                JobTitle = g.Key.PadRight(10, ' '),
                // 总额
                Total = Math.Round(g.Sum(s => s.Salary), 2, MidpointRounding.ToEven),
                Avg = Math.Round(g.Average(s => s.Salary), 2, MidpointRounding.ToEven),
                Count = g.Count()
            }).OrderBy(g => g.Total).ToList();
            Console.WriteLine("职称      \t总金额    \t平均工资  \t总人数");
            foreach (var g in group)
            {
                Console.WriteLine("{0}\t{1}\t{2}\t{3}", g.JobTitle, g.Total, g.Avg, g.Count);
            }
            Console.ReadKey();
        }
        static string CreateData()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            var fileName = Path.Combine(path, Guid.NewGuid().ToString("N") + ".txt");
            using var file = new FileStream(Path.Combine(path, fileName), FileMode.OpenOrCreate);
            var sb = new StringBuilder();
            int cnt = 1000;
            Random random = new Random();
            for (int i = 1; i <= cnt; i++)
            {
                var randomBands = salaryBands[random.Next(0, 3)];
                sb.AppendLine($"FirstName{i} LastName{i} {randomBands.Name}");
                sb.AppendLine($"{random.Next(randomBands.Floor, randomBands.Upper) + Math.Round(random.NextDouble(), 2)}");
            }
            var buffer = Encoding.Default.GetBytes(sb.ToString());
            file.Write(buffer, 0, buffer.Length);
            return fileName;
        }
    }

    struct SalaryBand
    {
        public string Name;
        public int Floor;
        public int Upper;
    }

    public record Teacher
    {
        public string FirstName { get; }

        public Teacher(string firstName, string type, double salary)
        {
            FirstName = firstName;
            Type = type;
            Salary = salary;
        }

        public string Type { get; }
        public double Salary { get; }
    }
}
Jonny-Xhl | 园豆:691 (小虾三级) | 2020-12-20 20:49
0

这也可以是毕业设计吗

不知道风往哪儿吹 | 园豆:2037 (老鸟四级) | 2020-12-21 09:00
0

毕业设计,这个可以忽悠到老师吗?老师都觉得太简单了吧

华临天下 | 园豆:1501 (小虾三级) | 2020-12-21 09:40
0

所以连毕业也要蒙混过关吗

ycyzharry | 园豆:25683 (高人七级) | 2020-12-22 00:18
0

这是毕业设计 ????

人间春风意 | 园豆:2780 (老鸟四级) | 2020-12-23 09:40
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册