In Progress

JAVA codes

Question 1

(Using the GregorianCalendar class) Java API has the GregorianCalendar in class in [url removed, login to view] package that can be used to obtain the year, month, and day of a date. The no-arg constructor constructs an instance for the current date, and the method get([url removed, login to view]), get(GregorianCalendar. MONTH), and get(GegorianCalendar.DAY_OF_Month) return the year, month, and day. Write a program to perform these two tasks.

Display the current year, month and day

The GregorianCalander class has the SetTimeInMillis(long), which can be used to set a specified elapsed time since January 1, 1970. Set the value to 1234567898765L and display the year, month and day.

Question 2

(The MyPoint class) Design a class called MyPoint to represent a point with x and y-coordinates. The class contains:

Two data fields x and y that represents the coordinates with get methods

A no-arg constructor that creates a point(0,0)

A constructor that constructs a point with specified coordinates

Two get methods for data fields x and y respectively.

A method named distance that returns the distance from this point to another point of the MyPoint type

A method named distance that returns the distance from this point to another point with specified x- and y- coordinates

Draw the UML diagram for the class. Implement the class. Write a test program that creates two points (0,0) and (10, 30.5) and displays the distance between them-

question 3

(Implementing MyStack using inheritance) In Listing 11.9, MyStack is implemented using composition. Create a new stack class that extends ArrayList.

Public class MyStack {

Private [url removed, login to view] list = new java .[url removed, login to view]();

Public Boolean isEmpty() {

Return [url removed, login to view]();

}

Public int getSize() {

Return [url removed, login to view]();

}

Public Object peek(){

Return [url removed, login to view](getSize() – 1);

}

Public Object pop(){

Object o = [url removed, login to view](getSize() – 1);

[url removed, login to view](getSize() – 1);

Return 0;

}

Public void push(Object o){

[url removed, login to view](0);

}

Public int search(Object o){

Return [url removed, login to view](o);

}

/**Override the toString in the Object class */

Public string toString(){

Return “stack:”+ [url removed, login to view]();

}

}

Listing 11.9

Draw the UML diagram for the classes. Implement Mystack. Write a test program that prompts the user to enter five strings and displays them in reverse order

Skills: Java

See more: implement mystack using inheritance, implementing mystack using inheritance, mystack java api, list methods package design, java obtain, java distance, january month, int size, month january, java mystack extends arraylist, java mystack arraylist reverse, mystack implemented using composition, set value 1234567898765l java, java 1234567898765l, java codes, boolean search string, get java, void

About the Employer:
( 2 reviews ) Short Hills, United States

Project ID: #1152176

Awarded to:

eperfections

Hi, I am JAVA Expert! I can do it in few hours. Please accept my bid. Thanks

$30 USD in 0 days
(269 Reviews)
7.0

3 freelancers are bidding on average $37 for this job

deadhunt

Please check PMB.

$50 USD in 2 days
(34 Reviews)
4.7
youssef13

please check PM

$30 USD in 0 days
(0 Reviews)
0.0