Question: Hello I need help with this one please I will leave the programs bellow than you for your help I really appreciate it import java.io.*;
Hello I need help with this one please I will leave the programs bellow than you for your help I really appreciate it



import java.io.*; import java.util.*;
/** * Hydra is a program that will simulate the work done for a * computational task that can be broken down into smaller subtasks. * * @author Charles Hoot * @version 5.0 */ public class Hydra {
public static void main(String args[]) { BagInterface
int startingSize;
System.out.println("Please enter the size of the initial head."); startingSize = getInt(" It should be an integer value greater than or equal to 1.");
// ADD CODE HERE TO CREATE AND INITIALIZE THE TWO BAGS
System.out.println("The head bag is " + headBag);
boolean noOverflow = true;
// ADD CODE HERE TO DO THE SIMULATION
if (noOverflow) { System.out.println("The number of chops required is " + workBag.getCurrentSize()); } else { System.out.println("Computation ended early with a bag overflow"); }
}
/** * Take one head from the headBag bag. If it is a final head, we are done with it. * Otherwise put in two heads that are one smaller. * Always put a chop into the work bag. * * @param heads A bag holding the heads yet to be considered. * @param work A bag of chops. * @return true if adding to the bags did not cause an overflow * */ public static boolean simulationStep(BagInterface
// COMPLETE THIS METHOD return false; }
/** * Get an integer value. * * @return An integer. */ private static int getInt(String rangePrompt) { Scanner input; int result = 10; // default value is 10 try { input = new Scanner(System.in); System.out.println(rangePrompt); result = input.nextInt();
} catch (NumberFormatException e) { System.out.println("Could not convert input to an integer"); System.out.println(e.getMessage()); System.out.println("Will use 10 as the default value"); } catch (Exception e) { System.out.println("There was an error with System.in"); System.out.println(e.getMessage()); System.out.println("Will use 10 as the default value"); } return result;
} }
import java.io.*; import java.util.*;
/** * LongestCommonSubsequence is a program that will determine the longest string that is * a subsequence of two input strings. This program applies a brute force solution technique. * * @author Charles Hoot * @version 5.0 */ public class LongestCommonSubsequence {
public static void main(String args[]) { BagInterface
Scanner input; input = new Scanner(System.in);
System.out.println("This program determines the longest string that is a subsequence of two input string."); System.out.println("Please enter the first string:"); String first = input.next();
System.out.println("Please enter the second string:"); String second = input.next();
// ADD CODE HERE TO CREATE THE BAG WITH THE INITIAL STRING ///vvvvvvvvv ADDED CODE vvvvvvvvvvvvvvvvvvvvvvvv toCheckContainer = new ArrayBag
System.out.println("The strings to check are: " + toCheckContainer); String bestSubsequence = new String("");
// ADD CODE HERE TO CHECK THE STRINGS IN THE BAG System.out.println("Found " + bestSubsequence + " for the longest common subsequence");
}
/** * Determine if one string is a subsequence of the other. * * @param check See if this is a subsequence of the other argument. * @param against The string to check against. * @return A boolean if check is a subsequence of other. */ public static boolean isSubsequence(String check, String against) { // ADD CODE HERE TO CHECK IF WE HAVE A SUBSEQUENCE return false; } }
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class LongestCommonSubsequenceTest {
@Test void testIsSubsequence() { Object[][] data = { { "", "", true }, { "A", "A", true }, { "A", "AA", true }, { "AA", "A", false }, { "A", "B", false }, { "WBCAX", "ZWABCEFAABX", true }, { "WBAFX", "ZWABCEFAABX", false }, { "WWFABA", "ZWABCEFAABX", false }, { "D", "ABC", false }, { "AA", "ABA", true }, { "AA", "AAA", true }, { "AABC", "ABBC", false }, { "ABBC", "ABCC", false }, { "ABCC", "CABAC", false }, { "ABA", "AA", false }, { "ABC", "CBACBA", false }, { "ABC", "CBACBACBA", true }, { "ABC", "BCABCA", true }, { "ABCD", "DCBADCBA", false }, { "ABFCD", "ADBAFDCBA", false }, { "ABFCD", "ADBADCBA", false }, { "ABCDF", "ADBADCBA", false }, { "ABADA", "BADABAABDBA", true }
}; for (int i = 0; i
}
}
Once again thank you so much for taking your time in helping me understand :)
In this lab you will complete two applications that use the Abstract Data Type (ADT) bag. Refer to the lab manual for specific instructions. Note that the lab manual contains the solutions to the pre-lab visualization exercises. To get started, download the Eclipse Project and import into Eclipse. Note that we will NOT be going through the Pre-Lab Visualization or Post-Lab Follow-Ups exercises described in the lab manual but the pseudocode for the algorithms you need to implement are included in the Hints section below. Students should focus on completing the implementation of the starting code following the steps in the Directed Lab Work section of the manual. To get 7 points out of 10 for the lab, Hydra.java should be complete and correct. Correctly implementing the method isSubsequence is worth 2 points out of 10 . To verify your implementation, run the JUnit test LongestCommonSubsequenceTest.java. Correctly implementing the code to determine the longest common subsequence is worth 1 point out 10. When you have completed the lab, you should submit the Eclipse Project files Hydra.java and LongestCommonSubsequence.java (if implemented) as the solution to this assignment. If you are unable to complete the lab in class, you should still submit your files with a comment that the lab is incomplete. You are welcome to complete the lab either on your own device or in class during Office Hours. Hints - You will need the String.substring method to solve the problem of generating new strings from test by removing each single character. The line below creates a new String by removing the character at position i(0= check length; - The algorithm, as described in the lab manual, for finding the longest subsequence is shown belov
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
