1) area() -> To calculate the area of given shape
2) salary() -> To calculate the salary given basic salary, da, hra.
3) percentage() -> To calculate the percentage given total mars and marks obtained.
4) Develop a program named 'PackageUse' to import the above package 'useFul' and use the method area().
5) Develop a program named 'Manager' calulate the salary. Import the above package 'useFul' and make use of salary() method.
6) Develop a program named 'Student' to calculate the percentage. Import the above package 'useFul' and make use of the method percentage().
7) Develop a program to create a package named 'useFullToo' inside the above package 'useFul' with one class named 'useMeToo' having a method to display the message "This is from Inside Package".
package useFul;
public class UseMe
{
public void area(int l, int b)
{
System.out.println("Area of shape Rectangle : " + (0.5F*l*b));
}
public void salary(int bs, int da, int hra)
{
System.out.println("Your salary is " + (bs+da+hra));
}
public void percentage(int total, int marks_obtained)
{
System.out.println("Your percentage: " +(((float)marks_obtained/total)*100));
}
}
/************************************************************************************************************
**************************************PackageUse.java********************************************************
************************************************************************************************************/
import useFul.*;
class PackageUse
{
public static void main(String[] args)
{
UseMe ob = new UseMe();
ob.area(10, 20);
}
}
/* OUTPUT
N:\Study Link\Exp 7>javac PackageUse.java
N:\Study Link\Exp 7>java PackageUse
Area of shape Rectangle : 100.0
*/
/************************************************************************************************************
*****************************************Manager.java********************************************************
************************************************************************************************************/
import useFul.*;
class Manager
{
public static void main(String[] args)
{
UseMe ob = new UseMe();
ob.salary(20000, 2000, 5000);
}
}
/* Output
N:\Study Link\Exp 7>javac Manager
.java
N:\Study Link\Exp 7>java Manager
Your salary is 27000
*/
/************************************************************************************************************
*****************************************Student.java********************************************************
************************************************************************************************************/
import useFul.*;
class Student
{
public static void main(String[] args)
{
UseMe ob = new UseMe();
ob.percentage(200, 150);
}
}
/* OUTPUT
N:\Study Link\Exp 7>javac Student
.java
N:\Study Link\Exp 7>java Student
Your percentage: 75.0
*/
/************************************************************************************************************
*****************************************useMeToo.ava********************************************************
************************************************************************************************************/
package useFul.useFullToo;
public class useMeToo
{
public void display()
{
System.out.println("This is from inside Package");
}
}
/************************************************************************************************************
*****************************************useMeToo.ava********************************************************
************************************************************************************************************/
import useFul.useFullToo.*;
class UseFullTooDemo
{
public static void main(String[] args)
{
useMeToo ob = new useMeToo();
ob.display();
}
}
/* OUTPUT
N:\Study Link\Exp 7>javac UseFullTooDemo.java
N:\Study Link\Exp 7>java UseFullTooDemo
This is from inside Package
*/
2) salary() -> To calculate the salary given basic salary, da, hra.
3) percentage() -> To calculate the percentage given total mars and marks obtained.
4) Develop a program named 'PackageUse' to import the above package 'useFul' and use the method area().
5) Develop a program named 'Manager' calulate the salary. Import the above package 'useFul' and make use of salary() method.
6) Develop a program named 'Student' to calculate the percentage. Import the above package 'useFul' and make use of the method percentage().
7) Develop a program to create a package named 'useFullToo' inside the above package 'useFul' with one class named 'useMeToo' having a method to display the message "This is from Inside Package".
package useFul;
public class UseMe
{
public void area(int l, int b)
{
System.out.println("Area of shape Rectangle : " + (0.5F*l*b));
}
public void salary(int bs, int da, int hra)
{
System.out.println("Your salary is " + (bs+da+hra));
}
public void percentage(int total, int marks_obtained)
{
System.out.println("Your percentage: " +(((float)marks_obtained/total)*100));
}
}
/************************************************************************************************************
**************************************PackageUse.java********************************************************
************************************************************************************************************/
import useFul.*;
class PackageUse
{
public static void main(String[] args)
{
UseMe ob = new UseMe();
ob.area(10, 20);
}
}
/* OUTPUT
N:\Study Link\Exp 7>javac PackageUse.java
N:\Study Link\Exp 7>java PackageUse
Area of shape Rectangle : 100.0
*/
/************************************************************************************************************
*****************************************Manager.java********************************************************
************************************************************************************************************/
import useFul.*;
class Manager
{
public static void main(String[] args)
{
UseMe ob = new UseMe();
ob.salary(20000, 2000, 5000);
}
}
/* Output
N:\Study Link\Exp 7>javac Manager
.java
N:\Study Link\Exp 7>java Manager
Your salary is 27000
*/
/************************************************************************************************************
*****************************************Student.java********************************************************
************************************************************************************************************/
import useFul.*;
class Student
{
public static void main(String[] args)
{
UseMe ob = new UseMe();
ob.percentage(200, 150);
}
}
/* OUTPUT
N:\Study Link\Exp 7>javac Student
.java
N:\Study Link\Exp 7>java Student
Your percentage: 75.0
*/
/************************************************************************************************************
*****************************************useMeToo.ava********************************************************
************************************************************************************************************/
package useFul.useFullToo;
public class useMeToo
{
public void display()
{
System.out.println("This is from inside Package");
}
}
/************************************************************************************************************
*****************************************useMeToo.ava********************************************************
************************************************************************************************************/
import useFul.useFullToo.*;
class UseFullTooDemo
{
public static void main(String[] args)
{
useMeToo ob = new useMeToo();
ob.display();
}
}
/* OUTPUT
N:\Study Link\Exp 7>javac UseFullTooDemo.java
N:\Study Link\Exp 7>java UseFullTooDemo
This is from inside Package
*/