Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey guys Im having trouble with a few simple functions i need to do for my class in Java... Any help would be greatly appreciated

Hey guys Im having trouble with a few simple functions i need to do for my class in Java... Any help would be greatly appreciated ...

class BetterLoop
{
public static boolean contains(int [] values, int v)
{
/* TO DO: if value v is in the array, return true.
If not, return false. Use a "foreach" loop.
*/
return true; // A bit optimistic, but a real boolean value.
}

}

__________________________________________________________________________

import java.util.LinkedList;
import java.util.List;
import java.util.Map;
class ExampleMap
{
public static List highEnrollmentStudents(
Map> courseListsByStudentName, int unitThreshold)
{
List overEnrolledStudents = new LinkedList<>();
/*
Build a list of the names of students currently enrolled
in a number of units strictly greater than the unitThreshold.
*/
return overEnrolledStudents;
}

}

_________________________________________________________

class SimpleArray
{
public static int [] squareAll(int values[])
{
/* TO DO: This size is not right. Fix it to work with any
input array. The length of an array is accessible through
an array's length field (e.g., values.length).
*/
int [] newValues = new int[1]; // This allocates an array of integers.
/* TO DO: The output array, newValues, should hold as
its elements the square of the corresponding element
in the input array.
Write a loop to compute the square of each element from the
input array and to place the result into the output array.
*/
return newValues;
}

}

___________________________________________________________________________________________

import java.util.List;
import java.util.LinkedList;
class SimpleList
{
public static List squareAll(List values)
{
List newValues = new LinkedList();
/* TO DO: The output list, newValues, should hold as
its elements the square of the corresponding element
in the input list.
Write a loop to add the square of each element from the
input list into the output list. Use a "foreach".
*/
return newValues;
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions