欢迎来到天天文库
浏览记录
ID:33946075
大小:62.44 KB
页数:8页
时间:2019-03-02
《c#第七章课后题答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceProj7_15{publicclassEmployee//普通职工类{privatedoublebsalary=1000;//基本工资privatedoublepsalary;//实际工资privateintn;//工作年数publicintpn{get{returnn;}set{n=value;}}publicdoublecompsalary()//计算普通员工工资{Console.Write("工作年数:
2、");pn=int.Parse(Console.ReadLine());psalary=bsalary+30*pn;returnpsalary;}}publicclassUEmployee:Employee//本科生职工类{newpublicdoublecompsalary(){return1.5*base.compsalary();}}classProgram{staticvoidMain(string[]args){Employeeemp1=newEmployee();Console.WriteLine("该普通职工工资:{0}",emp1.c
3、ompsalary());UEmployeeemp2=newUEmployee();Console.WriteLine("该本科生职工工资:{0}",emp2.compsalary());}}}usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceProj7_16{publicclassEmployee//普通职工类{privatedoublebsalary=1000;//基本工资privatedoublepsalary;//实际工资privateintn;//工
4、作年数publicintpn{get{returnn;}set{n=value;}}publicvirtualdoublecompsalary()//计算普通员工工资{Console.Write("工作年数:");pn=int.Parse(Console.ReadLine());psalary=bsalary+30*pn;returnpsalary;}}publicclassUEmployee:Employee//本科生职工类{publicoverridedoublecompsalary(){return1.5*base.compsalary();
5、}}publicclassGEmployee:Employee//研究生职工类{publicoverridedoublecompsalary(){return2*base.compsalary();}}classProgram{staticvoidMain(string[]args){Employeeemp1=newEmployee();Console.WriteLine("该普通职工工资:{0}",emp1.compsalary());UEmployeeemp2=newUEmployee();Console.WriteLine("该本科生职工工资
6、:{0}",emp2.compsalary());GEmployeeemp3=newGEmployee();Console.WriteLine("该研究生职工工资:{0}",emp3.compsalary());}}}usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceProj7_17{publicclassPerson//人类{privateintno;//编号privatestringname;//姓名publicvoidinput(){Console.Wr
7、ite("编号:");no=int.Parse(Console.ReadLine());Console.Write("姓名:");name=Console.ReadLine();}publicvoiddisp(){Console.WriteLine("编号:{0}",no);Console.WriteLine("姓名:{0}",name);}}publicclassStudent:Person//学生类{privatestringsclass;//班号privateintdegree;//成绩publicvoidinput(){base.input
8、();Console.Write("班号:");sclass=Console.ReadLine();Console.Wri
此文档下载收益归作者所有