This is homework but if you don't help me I will fail

So unless anyone wants to see my fail my programming class. HELP ME!!!!!!!!!!!

1) Create two new Vector objects, stored in separate variables
2) Print out each Vectors’ size, and all of the elements that they contain (using a single
System.out.println() statement for each Vector – see above)
3) Read in 4 Strings from the keyboard, one at a time, and insert each of them into the first Vector
object. Use the next() method from Scanner, NOT nextLine().
4) Read in 4 additional strings from the keyboard, one at a time, and insert each of them into the
second Vector object. Use the next() method from Scanner, NOT nextLine().
5) Print out each Vectors’ size, and all of the elements that they contain (using a single
System.out.println() statement for each Vector – see above)
6) Get an int i from the keyboard
7) Print out the element at index i in each of the two vectors
8) Remove the element at index i in each of the two vectors, and print out that you are doing so.
9) Insert the first element of the first Vector object to the second Vector object, and print out that you
are doing so.
10) Print out each Vectors’ size, and all of the elements that they contain (using a single
System.out.println() statement for each Vector – see above)
11) Get another String from the keyboard. Use the next() method from Scanner, NOT
nextLine().
12) Search the first Vector for that String, and print out the result of that search (this uses the
indexOf() method)
13) Print the first and last elements of Vector 1
14) Clear the second Vector (remove all elements) (and print that you are doing so)
15) Print out each Vectors’ size, and all of the elements that they contain (using a single
System.out.println() statement for each Vector – see above)

Welcome to the Vector Manipulation Program!
Creating new Vectors (step 1)
Vector 1 is size 0 and contains: [] (step 2)
Vector 2 is size 0 and contains: [] (step 2)
Please enter 4 strings: (step 3)
kiwi
lime
pear
LAB 3 and 4 – Double Value (30 pts.) due 10/20 by the start of LAB (Class)
orange
Please enter 4 more strings: (step 4)
mango
pineapple
grape
banana
Vector 1 is size 4 and contains: [kiwi, lime, pear, orange] (step 5)
Vector 2 is size 4 and contains: [mango, pineapple, grape, banana] (step 5)
Please enter an integer: (step 6)
3
Element at index 3 in Vector 1 is: orange (step 7)
Element at index 3 in Vector 2 is: banana (step 7)
Removing the element at index 3 of both vectors (step 8)
Adding first element of Vector 1 to Vector 2. (step 9)
Vector 1 is size 3 and contains: [kiwi, lime, pear] (step 10)
Vector 2 is size 4 and contains: [mango, pineapple, grape, kiwi] (step 10)
Please enter another String: (step 11)
pear
Search Vector 1 for pear returned: 2 (step 12)
The first element of Vector 1 is: kiwi (step 13)
The last element of Vector 1 is: pear (step 13)
Cleared Vector 2 (step 14)
Vector 1 is size 3 and contains: [kiwi, lime, pear] (step 15)
Vector 2 is size 0 and contains: [] (step 15)

Oh, this is supposed to be in Java btw.
Last edited on
Oh, this is supposed to be in Java btw.


A Java forum might be a better place to ask for help.
Surely there are some in here who know a bit of both :/
Do you know how to create an object?
Yes, I should. Vector ()?
Topic archived. No new replies allowed.