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

Create your own simple java application to generate x

Create your own simple Java application to generate X random Integer values between 0 and Y. Use command line arguments for entry of X and Y. Demonstrate your code compiles and runs without issue using screen captures as ...

Design your own java class that includes at least 3 data

Design your own Java Class that includes at least 3 data fields, 2 constructors and 4 methods. When designing your class, pick an object that you are familiar with and make it your own, realistic, yet simple design with ...

Assignmentthis assignment will give you a chance to

Assignment This assignment will give you a chance to exercise your knowledge of extending jQuery and of multimedia players like the JWPlayer. We're building on the "divide-text-into-spans" example we started in Homework ...

Programming assignmentyou to write a class named

Programming Assignment You to write a class named WeaklyCalendar. This class must be in a package named pa4. Note that the description of a programming assignment is not a linear narrative and often requires multiple rea ...

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 ...

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 ...

Assessment scenarioproblemjava program for a music social

Assessment Scenario/Problem Java program for a Music Social Network system. You can work on this coursework either alone or in a pair with a colleague, not necessarily from the same seminar or lab group. If you elect to ...

Java programmingscenario a mom and pop used car dealership

JAVA PROGRAMMING SCENARIO: A Mom and Pop used car dealership wants you to create a program that will manage their sales and inventory. They have provided a menu for you to follow. 1. Add To Inventory 2. Remove From Inven ...

Learning outcomes1use different program control statements

Learning Outcomes: 1. Use different program control statements in a programming language 2. Demonstrate the use of arrays with a programming language 3. Define and work with classes and objects in a programming language. ...

Problem specificationyou have been approached by a local

Problem Specification You have been approached by a local university for designing and implementing a room access control system on the university campus. Access to each room on each floor of each campus building is cont ...

  • 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

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

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen