Completed

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: design class named mypoint represent point coordinates, implement mystack using inheritance, implementing mystack using inheritance, mystack class java extends arraylist, draw uml diagram classes implement mystack, mypoint class write test program creates points, create stack class mystack extends arraylist class contains, data fields represent coordinates methods, java program design class named mypoint represent, mystack java api, create stack class extends arraylist, create implementing mystack using inheritance java program, display stack java extends arraylist, create stack class extends arraylist object peek, gregoriancalendar java api write date, design class named mypoint java, mystack class java, class named mypoint represent point coordinates, set value 1234567898765l display year month day, java mypoint class distance points, write java class called mypoint represent point coordinates, write class called mypoint represent point coordinates, stack class java, new in java 1.5, month of january

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