第一题看的脑壳疼,但是和第二题的意思差不多,我帮你做了第二题
public class List {public static void main(String[] args) {
Employee e1 = new Employee("张强","2010/09/01",6890)
e1.show("普通")
System.out.println("年纳税:"+e1.tax())
Manager m1 = new Manager("朱慧","2003/07/06",18530,38000)
m1.show("管理")
System.out.println("年纳税:"+m1.tax())
}
}
//下面是补全的代码
class Employee{
String name,date
double salary,bonus
Employee(String name,String date,double salary){
this.name = name
this.date = date
this.salary = salary
}
public void show(String str){
System.out.println("岗位:"+str)
System.out.println("姓名:"+name+",入职时间:"+date+",月薪:"+salary)
}
public double tax(){
if(salary <= 0){
throw new RuntimeException("工资不允许小于等于0")
}
else if(salary>3000 && salary<=5000){
salary = salary*0.05*12 //纳税这里我也不知道他们具体是怎么个算法,反正意思差不多,套进去就行了
}
else if(salary>5000 && salary<=10000){
salary = salary*0.1*12
}
else if(salary>10000 && salary<=15000){
salary = salary*0.15*12
}
else if(salary>15000){
salary = salary*0.2*12
}
return salary+(bonus*0.2)
}
}
class Manager extends Employee{
Manager(String name,String date,double salary,double bonus){
super(name,date,salary)
super.bonus = bonus
}
public void show(String str){
System.out.println("岗位:"+str)
System.out.println("姓名:"+name+",入职时间:"+date+",月薪:"+salary+",奖金:"+bonus)
}
}
没那么多时间,帮着写个第1题吧
// 编写求一个整数数组A[10,15,12,9,7]中最小元素min和元素之和sum的
int [] a = {10,15,15,9,7}
// 最小元素
int min=0
// 数组和
int sum=0
for(int i=0 i<a.length i++ ){
sum += a[i]
if(i == 0){
min = a[i]
}else{
if(a[i] < min){
min = a[i]
}
}
}
System.out.println("当前数组中最小的元素值是: "+min)
System.out.println("当前数组和是: "+sum)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)