Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask Java Expert


Home >> Java

problem 1: The purpose of this problem is to practice using ArrayLists.prepare a Java client file containing a mainmethod plus other methods as needed to solve the following problem (no class definition file is to be used). (Remember to solve this problem by calling a number of methods, rather than writing large code segments)

A) Generate 30 random numbers between 1 and 1000 inclusive and store these in 2 different Array Lists simultaneously as described below:

a) each ArrayList should be created using the default size (of 10)

b) the first ArrayList should hold the random numbers in the order they are generated (so it will need to automatically expand to accommodate the data)

c) the second ArrayList should hold the random numbers in sorted order. This will be accomplished by inserting each element as it is generated into the second ArrayList using a modified version of the insertion sort code we studied in class

  • make a method that contains your modified insertion sort code.  Your code should work with an ArrayList, not a Comparable[ ].

B) Display the 2 ArrayLists, hopefully demonstrating that your modified insertion sort works (note the first arraylist will display the unsorted data, while the 2ndarraylist should be sorted)

C) Create another method that will perform a selection sort on an arraylist and send it the first (unsorted) arraylist. This method should contain a modified version of the selection sort code we discussed in class; the code is modified to use an arraylist rather than a comparable[ ].

problem 2: The purpose of this problem is to practice using generics.

A) Create a generic class with a type parameter that simulates drawing an item at random out of a box. For ex the box might contain Strings representing names written on a slip of paper, or the box might contain Integers representing a random drawing for a lottery. Include the following methods in your generic class, along with any other methods you’d like:

a) an add( ) method that allows the user to add an object of the specified type.
b) an isEmpty( ) method to determine if the box is empty.
c) adrawItem( ) method that randomly selects an object from the box and returns it.  Return null if the box is empty.

B) In the driver file that tests your class create 2 boxes, one with the names of 7 friends, the other with numbers between 1 and 5 representing the amount of hours of home work you will do before going to the party you’ve been invited to. Use the add( ) methods to populate the 2 boxes, and the drawItem( ) methods for each box to determine i) how many hours of home work you will do before ii) going to the party with the friend you will invite (from the “friends” box)

Java, Programming

  • Category:- Java
  • Reference No.:- M91800

Have any Question? 


Related Questions in Java

Javapizzacontactlistat the beginning of all your programs

JavaPizza ContactList At the beginning of all your programs, put a comment box that includes the program name, your name, and a brief description of the program. Example: /************************************************ ...

The paris hotels company needs a computer program to track

The Paris Hotels Company needs a computer program to track their hotel occupancy for the hotels in their chain. Write a Java program that calculates the occupancy rate for each floor of a hotel. A hotel's occupancy rate ...

Casegreentek is a software solution company for smartphone

Case Greentek is a software solution company for smartphone and tablet devices. Current headquarter (HQ) locates in Sydney, 30 sale team members and 50 software engineers base in Singapore and Manila respective. The cycl ...

Submit one properly named rtf document inside your one jar

Submit one properly named .rtf document inside your one .jar file. lastname.firstname.mod4. 1. What is the characteristic behavior of a stack? 2. What is the characteristic behavior of a queue? 3. What are the advantages ...

Java programmingwrite a java application using netbeans

JAVA PROGRAMMING Write a Java application using NetBeans Integrated Development Environment (IDE) that calculates the total annual compensation of a salesperson. Consider the following factors: • A salesperson will earn ...

Write a java application using netbeans integrated

Write a Java application using NetBeans Integrated Development Environment (IDE) that calculates the total annual compensation of a salesperson. Consider the following factors: A salesperson will earn a fixed salary of . ...

Assignmentyou have to doone of the following1modify your

Assignment You have to doONE of the following: 1. Modify your Registration project(s) to use a Hash Table to maintain the student information instead of the sorted array or BST. Your hash function should be based on the ...

Java program for profhudaneed help with java program just

Java program for Prof.Huda Need help with java program ... just apply an example how i want my assignmemt to look like . you can use the same code to do the program .. by the way i"m using JCreater .. The assignment is : ...

Assignmentmust be done on bluejin this exercise you will

Assignment MUST BE DONE ON BLUEJ In this exercise you will create a simple VotingMachine. In the United States, when a candidate runs for office, the person is often identified as a Democrat, Republican, or Independent. ...

Write java program with eclipsinstructionswrite a program

Write java program with Eclips INSTRUCTIONS Write a program that will help a student practice basic math (addition, subtraction, multiplication, and division). Display a menu the student can select from. The student will ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro