Try the below mentioned code and graph your program based on the same i hope it will definitely help you:
Code:
class worker
{
public static int worker_no;
public static String name;
public static String designation;
public void showdata()
{
System.out.println("Worker number:--->"+worker_no);
System.out.println("Worker name:------>"+name);
System.out.println("Worker designation:--->"+designation);
}
}
class salary extends worker
{
public static float bsal,hr,da,tsal;
public void cal()
{
tsal=bsal+hr+da;
System.out.println("Total salary:---->"+tsal);
}
}
class workersal extends salary
{
public void calc()
{
if (bsal >=15000)
{
hr=0.3f*bsal;
da=0.2f*bsal;
}
else if (bsal >=10000)
{
hr=0.4f*bsal;
da=0.3f*bsal;
}
else
hr=0.3f*bsal+500;
da=0.2f*bsal+500;
}
public static void main(String args[])
{
workersal E=new workersal();
worker_no=Integer.parseInt(args[0]);
name=args[1];
designation=args[2];
bsal=Integer.parseInt(args[3]);
E.showdata();
System.out.println("Workerloyee Salary");
E.calc();
E.cal();
}
}
Bookmarks