?? salarry.java
字號:
import java.util.*;
import java.io.*;
class RenYuan {
String name;
int num;
double salary;
int shi;
double xiao;
public double compute(){
return salary;
}
}
class Manager extends RenYuan {
public double compute(){
salary=8000;
return salary;
}
}
class Salemanager extends RenYuan {
public double compute(){
Salarry k=new Salarry();
salary=5000+0.005*k.getzong();
return salary;
}
}
class Technician extends RenYuan{
public double compute(){
Salarry g=new Salarry();
salary=100.0*g.getshi();
return salary;
}
}
class Salesman extends RenYuan {
public double compute(){
Salarry h=new Salarry();
salary=0.04*h.getxiao();
return salary;
}
}
public class Salarry{
static char yes_no;
static double zong=0.0;
static int s0,s1,s2;
static int shijian=0;
static double xiaoshou;
static boolean g=false;
public static void main(String agrv[]){
do
{
System.out.println(" 歡迎使用工資管理系統(tǒng)!");
System.out.println("下面是注意事項(xiàng)!");
System.out.println("經(jīng)理和銷售經(jīng)理均為一人!");
System.out.println("銷售人員和兼職技術(shù)人員為多個!");
System.out.println("編號為大于0的正整數(shù)!");
System.out.println("下面就請您根據(jù)提示輸入全體人員的信息!");
System.out.println();
System.out.println();
System.out.println();
boolean r=false;
do{
try{ System.out.print("請輸入銷售人員的個數(shù):");
Scanner reader1=new Scanner(System.in);
s1=reader1.nextInt();
}
catch(InputMismatchException e){
System.out.println("輸入數(shù)據(jù)格式有誤,請重新輸入!");
continue;
}
r=true;
}while(r!=true);
boolean r0=false;
do{
try{ System.out.print("請輸入兼職技術(shù)人員的個數(shù):");
Scanner reader2=new Scanner(System.in);
s2=reader2.nextInt();
}
catch(InputMismatchException e){
System.out.println("輸入數(shù)據(jù)格式有誤,請重新輸入!");
continue;
}
r0=true;
}while(r0!=true);
RenYuan []A=new RenYuan[1+1+s1+s2+1];
for(int i=0;i<A.length;i++){
A[i]=new RenYuan();
A[i].num=0;
}
shuru(1,1,s1,s2,A);
print(1,1,s1,s2,A);
System.out.println(" 要繼續(xù)選擇嗎(y/n)?");
do { Scanner reader=new Scanner(System.in);
String s=reader.nextLine();
yes_no=s.charAt(0);
}while(yes_no!='Y'&&yes_no!='y'&&yes_no!='N'&&yes_no!='n');
}while(yes_no=='Y'||yes_no=='y');
}
public static double getzong(){
return zong;
}
public int getshi(){
return shijian;
}
public double getxiao(){
return xiaoshou;
}
public static boolean equal(int m,RenYuan A[]){
for(int i=1;i<A.length;i++){
if(A[m].num==A[i].num&&i!=m)
{
g=true;return g;
}
else
g=false;
}
return g;
}
public static int shuru(int a,int b,int c,int d,RenYuan A[]){
boolean r=false;
do{
try{System.out.print("請輸入經(jīng)理的編號:");
Scanner ji1=new Scanner(System.in);
A[a].num=ji1.nextInt();
}
catch(InputMismatchException e){
System.out.println("輸入數(shù)據(jù)格式有誤,請重新輸入!");
continue;
}
r=true;
}while(r!=true);
System.out.print("請輸入經(jīng)理的姓名:");
Scanner ji2=new Scanner(System.in);
A[a].name=ji2.nextLine();
Manager m=new Manager();
A[a].salary=m.compute();
for(int i=a+b+1,z=1;i<a+b+c+1;i++,z++){
boolean r1=false;
do{
try{ do{
System.out.print(z+"請輸入銷售人員的編號:");
Scanner ji5=new Scanner(System.in);
A[i].num=ji5.nextInt();
if(equal(i,A))
System.out.println("編號重復(fù),請重新輸入一個正整數(shù)!");
}while(equal(i,A));
}
catch(InputMismatchException e){
System.out.println("輸入數(shù)據(jù)格式有誤,請重新輸入!");
continue;
}
r1=true;
}while(r1!=true);
System.out.print(z+"請輸入銷售人員的姓名:");
Scanner ji6=new Scanner(System.in);
A[i].name=ji6.nextLine();
boolean r2=false;
do{
try{ System.out.print(z+"請輸入銷售人員的銷售額(元):");
Scanner ji7=new Scanner(System.in);
A[i].xiao=ji7.nextDouble();
}
catch(InputMismatchException e){
System.out.println("輸入數(shù)據(jù)格式有誤,請重新輸入!");
continue;
}
r2=true;
}while(r2!=true);
xiaoshou=A[i].xiao;
zong=zong+A[i].xiao;
Salesman sa=new Salesman();
A[i].salary=sa.compute();
}//for
boolean r3=false;
do{
try{ do{
System.out.print("請輸入銷售經(jīng)理的編號:");
Scanner ji3=new Scanner(System.in);
A[a+b].num=ji3.nextInt();
if(equal(a+b,A))
System.out.println("編號重復(fù),請重新輸入一個正整數(shù)!");
}while(equal(a+b,A));
}
catch(InputMismatchException e){
System.out.println("輸入數(shù)據(jù)格式有誤,請重新輸入!");
continue;
}
r3=true;
}while(r3!=true);
System.out.print("請輸入銷售經(jīng)理的姓名:");
Scanner ji4=new Scanner(System.in);
A[a+b].name=ji4.nextLine();
Salemanager s=new Salemanager();
A[a+b].salary=s.compute();
for(int i=a+b+c+1,v=1;i<a+b+c+d+1;i++,v++){
boolean r4=false;
do{
try{
do{
System.out.print(v+"請輸入兼職技術(shù)人員的編號:");
Scanner ji8=new Scanner(System.in);
A[i].num=ji8.nextInt();
if(equal(i,A))
System.out.println("編號重復(fù),請重新輸入一個正整數(shù)!");
}while(equal(i,A));
}
catch(InputMismatchException e){
System.out.println("輸入數(shù)據(jù)格式有誤,請重新輸入!");
continue;
}
r4=true;
}while(r4!=true);
System.out.print(v+"請輸入兼職技術(shù)人員的姓名:");
Scanner ji9=new Scanner(System.in);
A[i].name=ji9.nextLine();
boolean r5=false;
do{
try{ System.out.print(v+"請輸入兼職技術(shù)人員的工作時間(小時):");
Scanner ji10=new Scanner(System.in);
A[i].shi=ji10.nextInt();
}
catch(InputMismatchException e){
System.out.println("輸入數(shù)據(jù)格式有誤,請重新輸入!");
continue;
}
r5=true;
}while(r5!=true);
shijian=A[i].shi;
Technician t=new Technician();
A[i].salary=t.compute();
}//for
return 0;
}
public static void print(int a,int b,int c,int d,RenYuan A[]){
System.out.println();
System.out.println();
System.out.println();
System.out.println(" 全體人員的信息為:");
System.out.println("經(jīng)理的編號:"+A[a].num);
System.out.println("經(jīng)理的姓名:"+A[a].name);
System.out.println("經(jīng)理的工資:"+ A[a].salary+"元");
System.out.println("銷售經(jīng)理的編號:"+A[a+b].num);
System.out.println("銷售經(jīng)理的姓名:"+A[a+b].name);
System.out.println("銷售經(jīng)理的工資:"+A[a+b].salary+"元");
for(int i=a+b+1, n=1;i<=a+b+c;i++,n++){
System.out.println(n+"銷售人員的編號:"+A[i].num);
System.out.println(n+"銷售人員的姓名:"+A[i].name);
System.out.println(n+"銷售人員的銷售額:"+A[i].xiao+"元");
System.out.println(n+"銷售人員的工資:"+A[i].salary+"元");
}//for
System.out.println("公司本月銷售總額:"+getzong()+"元");
for(int i=(a+b+c+1), m=1;i<(a+b+c+d+1);i++,m++){
System.out.println(m+"兼職技術(shù)人員的編號:"+A[i].num);
System.out.println(m+"兼職技術(shù)人員的姓名:"+A[i].name);
System.out.println(m+"兼職技術(shù)人員的工作時間:"+A[i].shi+"小時");
System.out.println(m+"兼職技術(shù)人員的工資:"+A[i].salary+"元");
}//for
}
}//class Salarry
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -