CST-117 In-Class Assignment 7
A method stub, or signature, is the first line of a method.
Write a class that contains the following “stubs” for methods used in measurement conversion. You do not have to implement the methods.
Here’s an example:
Write a void method that takes an integer for the number of millimeters and displays the number of meters.
Correct response:
public void showMeters(int numMillimeters){}
Write a method that takes two integers and displays their sum.
public void displaySum(int numOne, int numTwo){
}
Write a method that takes five doubles and returns their
average.
public double averageOfFive(double num1, double num2, double num3,
double num4, double num5){
}
Write a method that returns the sum of two randomly generated
integers.
public int sumOfTwoRandomNumbers(){
}
Write a method that takes three integers and returns true if their
sum is divisible by 3 and false otherwise.
public boolean isDivisibleByThree(int num1, int num2, int
num3){
}
Write a method that takes two strings and displays the string that
has fewer characters.
public void displayShortestString (String strOne, string
strTwo){
}
Write a method that takes an array of doubles and returns the
largest value in the array.
public double getLargest(double numbers[]){
}
Write a method that generates and returns an array of fifty integer
values.
public int[] getFiftyInts(){
}
Write a method that takes two bool variables and return true if
they have the same value and false otherwise.
public bool areSame(bool flagOne, bool flagTwo){
}
Write a method that takes an int and a double and returns their
product.
public double getProduct(int num1, double num2){
}
or
public double getProduct(double num1, int num2){
}
Write a method that takes a two-dimensional array of integers and
returns the average of the entries.
public double getAverage(int numbers[][]){
}
CST-117 In-Class Assignment 7 A method stub, or signature, is the first line of a method....
A method stub, or signature, is the first line of a method. Write a class that contains the following “stubs” for methods used in measurement conversion. You do not have to implement the methods. Correct response: public void showMeters(int numMillimeters){} Write a method that takes two integers and displays their sum. Write a method that takes five doubles and returns their average. Write a method that returns the sum of two randomly generated integers. Write a method that takes three...
I need java code for the following problem.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a parameter. This method calculates and returns the largest even number in the list. If there are no even numbers in the array, the method should return 0. You can assume that the array is not empty. For example: Test Result int[] values = {1, 4, 5, 9}; System.out.println(getMaxEven(values)); 4 System.out.println(getMaxEven(new int[]{1, 3, 5, 9})); 0 public static int --------------------------------------------------------------------------------- 2. Write a static method...
1. Write a function named findTarget that takes three parameters: numbers, an array of integers - size, an integer representing the size of array target, a number The function returns true if the target is inside array and false otherwise 2. Write a function minValue that takes two parameters: myArray, an array of doubles size, an integer representing the size of array The function returns the smallest value in the array 3. Write a function fillAndFind that takes two parameters:...
Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method, but for now leave it empty. Then write a Java method getAverage which takes an array of integers as it’s argument. The method calculate the average of all the elements in the array, and returns that average. The method should work for an array of integers of any length greater than or equal to one. The method signature is shown below: public static double getAverage(...
in java Write a class named Palindrome.java and Write a method isPalindrome that takes an IntQueue as a parameter and that returns whether or not the numbers in the queue represent a palindrome (true if they do, false otherwise). A sequence of numbers is considered a palindrome if it is the same in reverse order. For example, suppose a Queue called q stores this sequence of values: front [3, 8, 17, 9, 17, 8, 3] back Then the following call:...
You must create a Java class named TenArrayMethods in a file named TenArrayMethods.java. This class must include all the following described methods. Each of these methods should be public and static.Write a method named getFirst, that takes an Array of int as an argument and returns the value of the first element of the array. NO array lists. Write a method named getLast, that takes an Array of int as an argument and returns the value of the last element...
Load to the IDEA the remaining classes from the provided Lab02.zip file. Repeat the previous project inside the ArraySetWithArray class. As shown in the UML diagram below ArraySetWithArray class does not utilize ResizableArrayBag object as its instance variable, it has setOfEntries defined as an array which should be dynamically resized if more room needed (double the size). displaySet method should check if the set is empty and display appropriate message; if the set is not empty should display the number...
Java question Q1) Use the following code snippet which generates a random sized array with random contents to complete the following problems: public int [] createRandomArray() { int size = (int) (Math.random() * 10) + 1; int[] array = new int [size]; for (int i = 0; i < array.length; i++) { array[i] = (int) (Math.random() * 10 ) + 1; } return array; } Assignment...
can i please get help on this? i don't know how to do it and I'm so confused. This is in java. This is what I need to do. Thank you so much. In this lab assignment, you are to write a class IntegerSet that represents a set of integers (by definition, a set contains no duplicates). This ADT must be implemented as a singly linked list of integers (with no tail reference and no dummy head node) , but...