# Hood College String Code Representation on Java Project These are some of the Java questions that I need to be solved. I use Dr-JAVA 2012 software to work

Hood College String Code Representation on Java Project These are some of the Java questions that I need to be solved. I use Dr-JAVA 2012 software to work on it and my professor need the screen shot of the output so pleaase make sure that they work on DR JAVA. 1-Write a static method named “tonnage” that accepts one parameter (a Scanner attached to an input file) whose
data represents a series of weights representing on-board freight for a truck. Your method should add up the weights
and display the total-number of items and the total-weight of the truck cargo.
The input consists of a series of records where the first entry is a Sting representing an item, followed by one or two
pairs of tokens, where each pair is an integer followed by a String representing the measure of weight
used. Measures are pounds, tons, and metric-tons. The measures are to be readcase-insensitively.
For example, if the input file contains the following lines of text:
Item-1 745 pounds
Item-2 2 Tons 550 pounds
Item-3 3 metric-Tons
Item-4 1 Metric-tons 75 pounds
In this example a ton is equal to 2000 pounds, a metric-ton equals 2205 pounds so the total pounds equals: 745 +
4000 + 550 + 6615 + 2205 + 75 = 14,190 pounds = 7 tons 190 pounds;
The output of your method should be: 4 items weighing 7 tons 190 pounds
You may assume that the file entries are well-formed as in the example above. You may use this file entries
provided to test your code, BUT your code should work correctly with any well-formed file. I will use a different
You may use the following code to test your program:
import java.util.*;
import java.io.*;
public class CountWeight {
public static void main(String[] args) throws FileNotFoundException {
Scanner fileIn = new Scanner(new File(“weights.txt”));
coinCounter(fileIn);
fileIn.close();
}
// *** your method code goes here ***
} // End of CountWeight class
2- Write a static method named “compareLines” that accepts one parameter (a Scanner attached to an input file).
Your method should compare each neighboring pair of lines (the 1st and 2nd lines, then the 3rd and 4th lines, and so
on) looking for indexes in both strings that contain vowels [a, e, i, o, u, y, A, E, I, O, U, Y] and should output the
index where both strings contained a vowel.
For example, in the strings “hello” and “bully, the characters at indexes 1 and 4 match since both contain vowels at
that index.
For each pair of lines, your method should print output showing the character indexes that match, separated by
spaces in the format shown below. If no characters match, print “none” instead as shown below.
For example, suppose the input file contains the following text.
(Line numbers and character indexes are shown around the input and matching characters are shown in bold, but
these markings do not appear in the actual file.)
0123456789012345678901234567890123456789 (String index)
The quick brown fox
Those achy down socks
Wheels on the school bus go round
The wipers go swish swish swish
This name is Robert Peltson
So long ‘n thanks for all the fish
Humpty Dumpty sat on a wall
and then he also had a great fall
When passed the above file, your method would produce the following output:
lines 1 and 2: 2 6 12 17
lines 3 and 4: 2 7 12 22
lines 5 and 6: none
lines 7 and 8: 12 15 18 21
Notice that lines are not generally the same length.
You may assume that the file contains an even number of lines.
Copy and paste the file lines above into a file named test.txt in your DrJava working directory to use with the test
program provided below.
import java.util.*;
import java.io.*;
public class MatchIndex {
public static void main(String[] args) throws FileNotFoundException {
Scanner fileIn = new Scanner(new File(“test.txt”));
matchIndex(fileIn);
}
// *** Your method code goes here ***
} // End of MatchIndex class
3- Write a static method named “mostVowels” that accepts two arrays of strings str1 and str2 as parameters
andreturns a new array str3 such that each element of str3 at each index i stores whichever string has greater number
of vowels when comparing the elements at that same index i in arrays str1 and str2. If there is a tie, take the element
from str1. You may create additional helper methods if desired.
For example, if a1 and a2 store the following elements:
String[] str1 = {“star”,
“pie”, “jelly bean”, “car”};
String[] str2 = {“cookie”, “fig”, “banana”, “soda”};
Then your method should return the new array
If the arrays str1 and str2 are not the same length, the result returned by your method should have as many elements
as the smaller of the two arrays. For example, if str1 and str2 store the following elements:
String[] str1 = {“Splinter”, “Leo”,
“April”, “Don”, “Raph”};
String[] str2 = {“Krang”, “Shredder”, “Bebop”};
Then your method should return the new array
{“Splinter”, “Leo”, “Bebop”}
Do not make any assumptions about the length of str1 or str2 or the length of the strings. You may assume that
neither array is null and that no element of either array is null.
You may use the following code to test your program:
Expected output is listed to the right of the method calls.
import java.util.*;
public class MoreVowels {
public static void main(String[] args) {
String[] a1 = {“star”, “pie”, “jelly bean”, “car”};
String[] a2 = {“cookie”, “fig”, “banana”, “soda”};
String[] a3 = mostVowels(a1, a2); // [cookie, pie, jelly bean, soda]
System.out.println(Arrays.toString(a3));
String[] a4 = {“Splinter”, “Leo”, “April”, “Don”, “Raph”};
String[] a5 = {“Krang”, “Shredder”, “Bebop”};
String[] a6 = mostVowels (a4, a5); // [Splinter, Leo, Bebop]
System.out.println(Arrays.toString(a6));
}
// *** Your method code goes here ***
} // End of MoreVowels class
4- Write a static method named “bigBeforeSmall” that accepts an array of integers as a parameter and rearranges its
elements so that all odd values appear before all evens. For example, if the following array is passed to your method:
String[] numbers = { “one”, “twelve”, “three”, “four”, “fourteen”, “six” };
Then after the method has been called, one acceptable ordering of the elements would be:
[“fourteen”, “twelve”, “three”, “four”, “one”, “six” ]
The exact order of the elements does not matter, so long as all longer Strings appear before all shorter
Strings. Another acceptable order would be:
[“fourteen”, “twelve”, “three”, “four”, “six”, “one” ]
Do not make any assumptions about the length of the array or the range of values it might contain. For example, the
array might contain no even elements or no odd elements. You may assume that the array is not null.
Hint: This is actually a sorting problem. In BubbleSort you tested pairs of elements and swapped them if the left
element is larger than the right element. In this problem, the swap happens when the left element has fewer
characters than the right element.
You also may not use any other data structures such as the ArrayList class from Chapter 10.
DO NOT use Arrays.sort in your solution.
You may use the following code to test your program:
If your method is modeled after a bubble sort, expected output is:
[“fourteen”, “twelve”, “three”, “four”, “one”, “six” ]
import java.util.*;
public class BigOnesFirst {
public static void main(String[] args) {
String[] numbers = {“one”, “twelve”, “three”, “four”, “fourteen”, “six”};
bigBeforeSmall(numbers);
System.out.println(Arrays.toString(numbers));
}
// *** Your method code goes here ***
} // End of BigOnesFirst class
5- Write a static method called “flip4” that takes an ArrayList of integer values as a parameter and that rewrites
successive sequences of four values in the list. For each sequence of four values, the method will swap the first
element and the fourth element and then swap the second element with the third element. For example, suppose that
a variable called list stores the following sequence of values:
[3, 8, 19, 42, 7, 26, 19, -8, 193, 204, 6, -4]
and we make the following call: flip4(list);
Afterwards the list should store the following sequence of values:
[42, 19, 8, 3, -8, 19, 26, 7, -4, 6, 204, 193]
Each sequence of three elements will be rotated so that the 3rd value becomes the 1st value and the other two are
moved to the next higher index; ie. the 1st becomes the 2nd and the 2nd becomes the 3rd. If the list has extra values
that are not part of a sequence of three, those values are unchanged. For example, if the list had instead stored:
[3, 8, 19, 42, 7, 26, 19, -8, 193, 204, 6, -4, 99, 2, 1]
The result would have been:
[42, 19, 8, 3, -8, 19, 26, 7, -4, 6, 204, 193, 99, 2, 1]
Notice that the values (99, 2, 1) are unchanged in position because they were not part of a sequence of four values.
You may use the following code to test your program:
Expected output is listed to the right of the print statements.
import java.util.*;
public class Flipper {
public static void main(String[] args) {
ArrayList list = new ArrayList();
System.out.println(list); // [3, 8, 19, 42, 7, 26, 19, -8, 193, 99, 2]
flip4(list);
System.out.println(list); // [42, 19, 8, 3, -8, 19, 26, 7, 193, 99, 2]
}
// *** Your method code goes here ***
} // End of Flipper class
6- Write a static method called “initials” that takes as a parameter a String containing a persons name. For example,
the following call:
initials(“Marie Elain Johnson”) should return “MEJ”.
Initials are formed by combining the capitalized first letters of each name component. Components in each name
will be separated by spaces, tabs, or the hyphen character. There might be extra spaces at the beginning or end of
the phrase. You may assume that the name String will have at least one name component.
You must extract the first letter of each name component and capitalize if needed and use that to build the name’s
initials. In the event of a hyphenated name, like Wilson-Smith, you must first replace the hyphen with a space
character
You may use the following code to test your program:
Expected output is listed to the right of the method calls.
import java.util.*;
public class Initials {
public static void main(String[] args) {
System.out.println(initials(“John Allen Jay”));
// “JAM”
System.out.println(initials(” Lisa Wilson”));
// “LW”
System.out.println(initials(” Quinton “));
// “Q”
System.out.println(initials(“lisa ann marie Kiley-Marsh”)); // “LAMKM”
}
// *** Your method code goes here ***
} // End of Initials class
7- Write a static method called “removeDuplicates” that takes an ArrayList of Strings as a parameter. It should first
sort the ArrayList using the sort function of the Containers helper class and then remove any duplicates so that only
one of any series of duplicates remains in the ArrayList.
For example, suppose that the parameter is an ArrayList named a containing:
[“clam”, “squid”, “squid”, “squid”, “clam”, “octopus”, “octopus”, “shrimp”]
Then after calling “removeDuplicates(list)” the ArrayList a should contain:
[“clam”, “octopus”, “shrimp”, “squid”]
Please note: quotation marks would not appear in the actual output of the ArrayList, they are only included here for
clarity. The actual ArrayList output would be:
[clam, octopus, shrimp, squid]
You may use the following code to test your program:
Expected output is listed to the right of the print statement.
import java.util.*;
public class RemoveDuplicates {
public static void main(String[] args) {
ArrayList list = new ArrayList();
squeeze(list);
System.out.println(list); // [clam, octopus, shrimp, squid]
}
// *** Your method code goes here ***
} // End of RemoveDuplicates class

attachment

Don't use plagiarized sources. Get Your Custom Essay on
Hood College String Code Representation on Java Project These are some of the Java questions that I need to be solved. I use Dr-JAVA 2012 software to work
Just from \$13/Page
Calculate the Price of your PAPER Now
Pages (550 words)
Approximate price: -

Why Choose Us

Top quality papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

We have hired a team of professional writers experienced in academic and business writing. Most of them are native speakers and PhD holders able to take care of any assignment you need help with.

Free revisions

If you feel that we missed something, send the order for a free revision. You will have 10 days to send the order for revision after you receive the final paper. You can either do it on your own after signing in to your personal account or by contacting our support.

On-time delivery

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & confidential

We use several checkers to make sure that all papers you receive are plagiarism-free. Our editors carefully go through all in-text citations. We also promise full confidentiality in all our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.