Trying to figure out these methods for comp sci class and I really don't understand. Any help would be really appreciated.
/**
*
*/
public static int [] setNums(String vals)
{
//this is a helper method to convert a string to an
array for searching purposes
//declare and instantiate an array
with length as the number of chars in vals
//lopp through each char in
vals
//add that char to the array at the
next index
//return the array
return null;
}
/**
*
*/
public static int search(int [] valNums, int target,
int inum)
{
/*
if ( num is equal to the length )
return a negative number
otherwise if the value at num is equal to the target
return num
else
return call with list, target and num plus 1
*/
return 0;
}
public static int[] setNums(String vals) { //this is a helper method to convert a string to an array for searching purposes //declare and instantiate an array with length as the number of chars in vals //lopp through each char in vals //add that char to the array at the next index //return the array int[] arr = new int[vals.length()]; for (int i = 0; i < vals.length(); i++) { arr[i] = vals.charAt(i); } return arr; } public static int search(int[] valNums, int target, int inum) { /* if (num is equal to the length) return a negative number otherwise if the value at num is equal to the target return num else return call with list, target and num plus 1 */ if (inum == valNums.length) return -1; else if (valNums[inum] == target) return inum; else return search(valNums, target, inum + 1); }
Trying to figure out these methods for comp sci class and I really don't understand. Any...
Hi I really need help with the methods for this lab for a computer science class. Thanks Main (WordTester - the application) is complete and only requires uncommenting to test the Word and Words classes as they are completed. The needed imports, class headings, method headings, and block comments are provided for the remaining classes. Javadocs are also provided for the Word and Words classes. Word The Word class represents a single word. It is immutable. You have been provided...
I am trying to understand how to manipulate the Gregorian Calendar so that I can convert my answer into a string format. What I'm hoping to do is to do is return string to a different file to add to a string in separate file (Object-oriented exercise between files), but once I can convert this into a string I can convert this file on my own. I added the System.out.println() to show what the results should look like. In other...
Hello, I am currently taking a Foundations of Programming course where we are learning the basics of Java. I am struggling with a part of a question assigned by the professor. He gave us this code to fill in: import java.util.Arrays; import java.util.Random; public class RobotGo { public static Random r = new Random(58); public static void main(String[] args) { char[][] currentBoard = createRandomObstacle(createBoard(10, 20), 100); displayBoard(startNavigation(currentBoard)) } public static int[] getRandomCoordinate(int maxY, int maxX) { int[] coor = new...
Java StringNode Case Study: Rewrite the following methods in the StringNode class shown below. Leave all others intact and follow similar guidelines. The methods that need to be changed are in the code below. - Rewrite the indexOf() method. Remove the existing recursive implementation of the method, and replace it with one that uses iteration instead. - Rewrite the isPrefix() method so that it uses iteration. Remove the existing recursive implementation of the method, and replace it with one that...
Objectives Problem solving using arrays and ArrayLists. Abstraction. Overview The diagram below illustrates a banner constructed from block-letters of size 7. Each block-letter is composed of 7 horizontal line-segments of width 7 (spaces included): SOLID as in block-letters F, I, U, M, A, S and the blurb RThere are six distinct line-segment types: TRIPLE as in block-letter M DOUBLE as in block-letters U, M, A LEFT_DOT as in block-letters F, S CENTER_DOT as in block-letter...
Hello, I am having trouble with a problem in my C language class. I am trying to make a program with the following requirements: 1. Use #define to define MAX_SIZE1 as 20, and MAX_SIZE2 as 10 2. Use typedef to define the following struct type: struct { char name[MAX_SIZE1]; int scores[MAX_SIZE2]; } 3. The program accepts from the command line an integer n (<= 30) as the number of students in the class. You may assume that the...
I need this program converted to c++ Please help if you can import java.util.*; // Add two arrays of the same size (size) // Each array is a representation of a natural number // The returned array will have the size of (size + 1) elements public class Fibonacci { private static String arrToString(int[] arr) { String s = ""; for (int i = 0; i < arr.length; i++) { s = s + arr[i]; }...
Programming assignment for Java: Do not add any other instance variables to any class, but you can create local variables in a method to accomplish tasks. Do not create any methods other than the ones listed below. Step 1 Develop the following class: Class Name: College Degree Access Modifier: public Instance variables Name: major Access modifier: private Data type: String Name: numberOfCourses Access modifier: private Data type: int Name: courseNameArray Access modifier: private Data type: String Name: courseCreditArray Access modifier:...
Given java code is below, please use it! import java.util.Scanner; public class LA2a { /** * Number of digits in a valid value sequence */ public static final int SEQ_DIGITS = 10; /** * Error for an invalid sequence * (not correct number of characters * or not made only of digits) */ public static final String ERR_SEQ = "Invalid sequence"; /** * Error for...
Hey I really need some help asap!!!! I have to take the node class that is in my ziplist file class and give it it's own file. My project has to have 4 file classes but have 3. The Node class is currently in the ziplist file. I need it to be in it's own file, but I am stuck on how to do this. I also need a uml diagram lab report explaining how I tested my code input...