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 don't really understand how to make the scores show up and how to make it start over. I honestly only half understand the things I've used to piece this together to make this work so far. but this is what I was asked to do..... read a user's first and last name read three integer scores, calculate the total and average determine the letter grade based on the following criteria - Average 90-100 grade is A, 80-89.99 grade is...
I need the following merge-sort assignment completed using the "ArrayList<Comparable>" (the part I'm really stuck on) with comments: import java.util.ArrayList; public class Mergesort { /** * Sorts list given using the mergesort algorithm * @param list the list to be sorted * @param first the index of the first element of the list to be sorted * @param last the index of the last element of the list to be sorted */ public static void mergesort(ArrayList<Comparable> list, int first, int...
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...
Does my code have any errors? I feel pretty confident. //Define a class PolicyHolder class PolicyHolder { //Declare variable private int policy_Number; //Declare variable private int customer_Age; //Declare variable private int number_Of_Accidents; //Define a constructor public PolicyHolder(int policy_Number, int customer_Age,int number_Of_Accidents) { //Set policy number this.policy_Number = policy_Number; //Set number of accidents this.number_Of_Accidents = number_Of_Accidents; //If customers age is greater than or equals 14 and less than or equals 125 */ if(customer_Age >= 14 && customer_Age <= 125)...
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...
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...
Below is my code and the instructions for the code. I can't figure out what's wrong. Please help. Tasks This lab has two parts: Writing a searching function for 1D arrays. Writing a simple class. Part 1 – Searching Continuing with arrays, we will now expect you to find information in an array and derive useful properties from the information stored in an array. Start Eclipse. Change the workspace directory location to something "safe". You may want to temporarily choose...
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]; }...