Question: JAVA- Complete this code as the comments describe: import java.util.*; class Person { private String lastName; private String firstName; private int age; public Person(String first,

JAVA- Complete this code as the comments describe:

import java.util.*;

class Person {

private String lastName;

private String firstName;

private int age;

public Person(String first, String last, int age) {

lastName = last;

firstName = first;

age = age;

}

@Override

public String toString() {

String result = "";

//!!! return "person info: firstName lastName, age"

return result;

}

public int getAge() {

return age;

}

}

public class Lab7

{

public static void main(String[] args) {

testStack();

testQueue();

}

private static void testStack() {

Stack personStack = new Stack<>();// JDK stack has no limits

//!!! add five persons with different names and ages

//!!! print contents of the stack

//!!! find a person with smallest age and prints the person

}

private static void testQueue() {

Queue intQueue1 = new LinkedList<>();

PriorityQueue intQueue2 = new PriorityQueue<>();

//!!! Add 10 random numbers (0 ~ 99) to queue and priority queue

//!!! Each queue should have different random numbers

//!!! Use offer for queues

//!!! Find the smallest number from all.

//!!! Use an iterator for intQueue1.

//!!! Remove all elements from both queues

//!!! For each element removed, print content of the queues

//!!! Use remove for queue

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!