Expert answer:Information Technology

Solved by verified expert:Hello my professors,How are you doing?Can you please help me for my assignment for Java so it is due after 24 hours please?Thanks
hw.docx

Unformatted Attachment Preview

Don't use plagiarized sources. Get Your Custom Essay on
Expert answer:Information Technology
Just from $10/Page
Order Essay

1/Complete the class code below and include a method named “search” that takes two String
parameters, a string to search and the other a target string to search for in the first string.
The search method will return an integer representing the number of times the search string
was found. The string being searched is a super-string formed by joining all lines of a text file,
so we might expect to get multiple hits with our method.
HINT: walk the String in a loop and use .substring(start, end) to examine a targetsized segment of the input string for equality to your target word.
public class WordSearch {
public static void main(String[] args) {
String fileName = “story.txt”;
String target = “help”;
Scanner fileIn = new Scanner(new File(fileName));
String story = “”;
while(fileIn.hasNextLine()) {
story += fileIn.nextLine(); // Build a super-String
}
System.out.println(“(” + target + “) found ” + search(story, target) + ” times”);
}
// method code here
} // end of WordSearch class
********* ANSWER for 1 ************
2/Complete the class code below and using only the main method, add code to make an
EXACT COPY of the input file to an output file named copyOf_.
For example, if we input the file named story.txt our class will make an exact copy of the file,
but save it under the name copyOf_story.txt
public class CopyFile {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.println(“Enter name of the file to copynFileName –> “);
// Your code here
}
} // end of CopyFile class
******** ANSWER FOR 2*******
——————————————————————————————-3/Write a static method named allDivide that takes an array of integers and an integer divisor
as parameters and returns a boolean value indicating whether or not ALL of the values in the
array are divisible by the divisor (true for yes, false for no).
For example, if a variable called list stores the following values:
int[] list = {18, 6, 27, 15, 24, 3, 48};
Then the call of allDivide(list, 3) should return “true” because each of these integers is evenly
divisible by 3.
If instead the list had stored these values:
int[] list = {18, 6, 27, 15, 24, 10, 3, 48};
Then the call should return “false” because, although most of these values are evenly divisible
by 3, the value 10 is not.
public class AllDivide {
public static void main(String[] args) {
int[] list1 = {18, 6, 27, 15, 24, 3, 48};
int[] list2 = {18, 6, 27, 15, 24, 10, 3, 48};
int divisor = 3;
System.out.println(“List1 ” + (allDivide(list1, 3)? “does”:”don’t”)
+ ” divide by ” + divisor);
System.out.println(“List2 ” + (allDivide(list2, 3)? “does”:”don’t”)
+ ” divide by ” + divisor);
}
// your code here
} // end of AllDivide class
******* ANSWER FOR 3 *********
——————————————————————————————–
4/Write a static method named “hasNoDuplicates” that takes an array of Strings as a
parameter and that returns a boolean value indicating whether or not any of the Strings in
the array are duplicated (true for yes, false for no).
For example, if a variable called list stores the following values:
String[] list = {“a”, “bb”, “acb”, “POP”, “dad”, “John”, “no”, “yes”};
Then the call of hasNoDuplicates(list) should return “true” because there are no duplicated
values in this list.
If instead the list stored these values:
String[] list = {“a”, “bb”, “acb”, “POP”, “dad”, “John”, “no”, “yes”, “no”};
Then the call should return “false” because the value “no” appears twice in this list. Notice
that given this definition, a list of 0 or 1 elements would be considered unique.
public class HasDuplicates {
public static void main(String[] args) {
String[] list1 = {“a”, “bb”, “acb”, “POP”, “dad”, “John”, “no”, “yes”};
String[] list2 = {“a”, “bb”, “acb”, “POP”, “dad”, “John”, “no”, “yes”, “no”};
System.out.println(“List1 ” + (hasDuplicates(list1)? “does”:”doesn’t”)
+ ” contain duplicates”);
System.out.println(“List2 ” + (hasDuplicates(list2)? “does”:”doesn’t”)
+ ” contain duplicates”);
}
// your code here
} // end of HasDuplicates class
***ANSWER for 4:******
——————————————————————————————-5/Complete the class code below and include a method named partition which takes an
integer array and a partition integer as parameters and then partitions the original array into
two new arrays where elements of the first array are all less than or equal to the partition
integer and the second array are all greater than the partition integer.
The method should print the original array, followed by the lower partition and finally the
upper partition. Nothing should be returned by the method.
For example, given int[ ] arr = {1, 45, 16, 7, 39, 6, 5, 11, 72, 31, 15} a method call to partition(arr,
11) should output:
[1, 45, 16, 7, 39, 6, 5, 11, 72, 31, 15]
[1, 5, 6, 7, 11]
[15, 16, 31, 39, 45, 72]
public class Partition {
public static void main(String[] args) {
int[] arrayToPartition = {1, 45, 16, 7, 39, 6, 5, 11, 72, 31, 15};
int partitionNumber = 11;
partition(arrayToPartition, partitionNumber);
}
// your method code here
} // end of Partition class
***ANSWER For 5********

Purchase answer to see full
attachment

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 30% with the discount code ESSAYSHELP