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
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

Popular posts from this blog

Program to define a class 'employee' with data members as empid, name and salary. Accept data for 5 objects using Array of objects and print it.

Define a class Student with four data members such as name, roll no.,sub1, and sub2. Define appropriate methods to initialize and display the values of data members. Also calculate total marks and percentage scored by student.

Program to input age from user and throw user-defined exception if entered age is negative