Rational Number Class in Java

Only available on StudyMode
  • Download(s) : 506
  • Published : October 21, 2012
Open Document
Text Preview
RATIONAL NUMBER CLASS IN JAVA

AIM
To write a program to find the rational form of rational number. ALGORITHM
1. Start the program.
2. Declare the class name as rational and assign num, den as two parameters. 3. Declare constructor as rational and numerator and denominator as parameter. 4. Then write to string () method to print the rational class object as a string. 5. To get the GCD value using static method use GCD (int m, int n) method. 6. Get the num and den from the user by using string[].

7. The error by using try, catch blocks.
8. Stop the program.

DATE CLASS IN JAVA

AIM
To develop a date class in java similar to the one in java.util.package using java doc commands.

ALGORITHM
1. Start the program
2. Define a class myDate that inherits the Date class from java.util.package. 3. Declare the variables required to store the information regarding data and time. 4. Override the methods to access the date and time properties of the system. 5. Use to string() method to efficiently display the class in string representation. 6. Use java doc commands to create documentation of the program. 7. Stop the program.

IMPLEMENTATION OF LISP-LIKE LIST

AIM
To write a java program to execute LISP-LIKE LIST in java.

ALGORITHM
1. Start the program.
2. Create a class to implement the LISP-LIKE LIST and its operation. 3. Get an array of input from the user and store it in the zeroth index of LISP-LIKE LIST, Next data in first index and so on. 4. When the index is given by the user as input display the address in which the indexed data are stored. 5. On users request for the given index display all the data stored array format. 6. Stop the program.

JAVA INTERFACE FOR ADT STACK

AIM
To write a java program to design a java interface for ADT stack.

ALGORITHM
Array List Class

1. Start the program.
2. Declare the class named ArrayList Example and create an object named arrlist. 3. Insert the elements using the data () function.
4. Print the array with the corresponding elements.
5. Remove each of the elements by specifying the position and using the remove() function. 6. Display the array after the declaration.
7. Stop the program.

ALGORITHM
Linked List Class
1. Start the program.
2. Declare the class named Linked List Example and create an object named Linked List. 3. Insert the element one by one to the list by using the add () function. 4. Print List the corresponding element.

5. Remove each of the value by providing the remove() function. 6. Display the result after deletion.
7. Stop the program.

ALGORITHM
Stack Class
1. Create a class named stack methods.
2. Specify the function definition for pop and push operation. 3. Insert element to the stack by push function operation. 4. Remove element from the stack by pop operation.
5. Display the elements in the stack.
6. Stop the program.

POLYMORPHISM

AIM
To write a Test program to demonstrate polymorphism by designing a vehicle class.

ALGORITHM
1. Start the program.
2. Create an interface “vehicle” to represent the properties number of wheels and vehicles type. 3. Implement the vehicle interface for the two objects and AutoRicksaw. 4. Define the methods declared in the vehicle interface in both the class. 5. Display the details of the vehicle by extending the classes in the polyvehicle class. 6. Stop the program.

IMPLEMENTATION OF INTERFACE

AIM
To design a java interface to the implementation.

ALGORITHM
1. Start the program.
2. Declare and initialize the interface.
3. Create a class as shape.
4. Create a class circle and square by extends the shape class and implements the interface shapes. 5. Create a main class as circle square Demo.
6. Create the object for the classes circle and shape.
7. Call the objects...
tracking img