import java.util.*;
class Test{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.print("Enter Name: ");
String name=sc.nextLine();
System.out.println("Enter E for Entry Level employee");
System.out.println("Enter M for Mid Level employee");
System.out.println("Enter T for Top Tier Level employee");
char type=sc.next().charAt(0);
//clear buffer
sc.nextLine();
System.out.print("Enter date of joining: ");
String doj=sc.nextLine();
//create a Salesperson
Salesperson sp=new Salesperson(name,doj,type);
//compute the comission
sp.Calculate_quarterly_sales();
//display the resutl
sp.display();
}
}
class Salesperson{
//member variables
private String name;
private String doj;
private char type;
private double comm_1;
private double comm_2;
//constructor
Salesperson(String name,String doj,char type)
{
this.name=name;
this.doj=doj;
this.type=type;
this.comm_1=0;
this.comm_2=0;
}
void Calculate_quarterly_sales()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the total sales for first six months: ");
double sales1=sc.nextDouble();
System.out.print("Enter the total sales for next six months: ");
double sales2=sc.nextDouble();
if(type=='E')
{
comm_1=(5*sales1)/100;
comm_2=(5*sales2)/100;
}
else if(type=='M')
{
comm_1=(10*sales1)/100+6000;
comm_2=(10*sales2)/100+6000;
}
else{
comm_1=(20*sales1)/100+12000;
comm_2=(20*sales2)/100+12000;
}
}
String getType()
{
if(type=='E')
return "Entry Level employee";
else if(type=='M')
return "Mid Level employee";
else
return "Top Tier employee";
}
void display()
{
System.out.println("\nSalesperson Information:");
System.out.println("Name: "+name);
System.out.println("Type: "+getType());
System.out.println("Date Of Joining: "+doj);
System.out.printf("Comission for Jan-June: %.2f\n",comm_1);
System.out.printf("Comission for July-December: %.2f\n",comm_2);
}
}
Comments
Leave a comment