Program to define a package named 'useFul' with a class named 'UseMe'
In this program, we have created a package useFul and put the UseMe class in that package. Compile this program using java compiler then you will get a .class file in given package.In this program, we have created a package useFul and put the UseMe class in that package. Compile this program using java compiler then you will get a .class file in given package.
PROGRAM
PROGRAM
package useFul;
public class UseMe
{
public void area(double length, double breadth)
{
double area = length * breadth;
System.out.println("Length of Rectangle = "+length);
System.out.println("Breadth of Rectangle = "+breadth);
System.out.println("Area of Rectangle = "+area);
}
public void salary(double basic_sal, double da, double hra)
{
double gross_sal = basic_sal + da + hra;
System.out.println("Basic salary = "+basic_sal);
System.out.println("DA = "+da);
System.out.println("HRA = "+hra);
System.out.println("Gross Salary = "+gross_sal);
}
public void percentage(int tot_marks, int obt_marks)
{
double per = (double)obt_marks / tot_marks * 100;
System.out.println("Total marks = "+tot_marks);
System.out.println("Obtained marks = "+obt_marks);
System.out.println("Percentage = "+per);
}
}
OUTPUT
C:\>javac -d . UseMe.java