please help me with this question
Intellisense shows the signature for your method:
static
double DoSomething(int, double)
Assuming you had variables answer and value1 of double type, which
had 0 and 25.8712 stored in their cells respectively (answer holds
0, value1 holds 25.8712). If you wanted to send 100 as the first
argument to the method and the current contents of value1 as the
second argument and have the method return some calculated value
back to the memory location answer in Main( ) _______________ would
invoke or call your method.
Answer is :
answer = DoSomething(100,value1);
Explanation:
The above statement will invoke the method. Since
DoSomething
is a static method, no object required to call or invoke the
method.
So, the method is invoked directly with "100" and "value1"
parameters.
Result returned from the DoSomething will be stored in the
variable
"answer".
Sample Java Code: (SampleEx.java)
public class SampleEx
{
public static void main(String args[])
{
//variables
double answer=0;
double value1=25.8712;
//invoking the method
answer
=DoSomething(100,value1);
//printing the contents of the
answer variable
System.out.println(answer);
}
//method which adds the parameters and return
public static double DoSomething(int a,double b)
{
return a+b;
}
}
SCREENSHOT FOR OUTPUT:
please help me with this question Intellisense shows the signature for your method: static double DoSomething(int,...
Consider the following methods’ headers: public static int one(int a, char b, double c, String d) public static double two(double x, double y) public static char three(int r, int s, char t, double u) Answer the following questions: Q1) What is the signature of method one? Answer: Q2) What is the return type of method two? Answer: Q3) What the formal parameters of method three? Answer: Q4) How many actual parameters are needed to call the method three? Answer: Q5)...
Write a program named Remainder.java then implement the following method: public static int divisibleBy(int[] arr, int M, int K) this method determines the number of elements in the int array (arr) that are divisible by M but not K. Then write code inside main method to test your method: your main method accepts three numbers from the command argument list, N, M, K, use the first number to create int array with size of N, assign random number between 0...
QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...
You will implement the following method public static int[] linearSearchExtended(int[][] numbers, int key) { // Implement this method return new int[] {}; } There is a utility method provided for you with the following signature. You may use this method to convert a list of integers into an array. public static int[] convertIntegers(List<Integer> integers) Provided code import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Scanner; public class MatrixSearch { // This method converts a list of integers to an array...
with arays of varius sizes: Write the follawing methuds and test the { public static double getMax( double[] list double max-D.0 max = l tst[0]; //initialize max to first elonent of list for 《int i-1; ic 118t·length ; it+) { if (11st [1] > max) max = list[i]; a. illArray WithRandomNumhers melhud Tt is a void methad with onw perauucter of type double array. I lils the aay with raadom mimhers in the range of 0.0 o 100.0 It is...
3. Consider the mystery method given. public static int mystery ( int n) [ if (n == 0 ) { return 1; How do we get the values for recurse? else if (n%2 == 0 ) { int recurse = mystery ( n - 1); int result = recurse + n; return result; since n =5, we go to the else statement and do int recurse = mystery(5-1) which equals 4? why is 3 written? else { int recurse =...
Our 1st new array operation/method is remove. Implement as follows: public static boolean remove( int[] arr, int count, int key ) { 1: find the index of the first occurance of key. By first occurance we mean lowest index that contains this value. hint: copy the indexOf() method from Lab#3 into the bottom of this project file and call it from inside this remove method. The you will have the index of the value to remove from the array 2:...
Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...
1.) Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would order the values in the bArray array in ascending order. ___________________ HINT: You must write the full statement which includes a call to a method in the Array class. 2.) Using the following declarations and a member of the Array class, int [ ] bArray =...
Question 1 Answer the questions below about this function prototype: double coinTotal (double coinValue, int nCoins); What is the type of the return value? How many parameters does the function take? What is the name of the function? Question 2 These are defined in the function heading and tell a user what data needs to be sent to a function. Question 3 What is the term used for a variable sent as data in a function call, such as n1...