Ask Ask the the user user for for anan array array size. size. Then Then receive
ID: 3631647 • Letter: A
Question
Ask Ask the the user user for for anan array array size. size. Then Then receive receive this thisnumber of double values. Place numbers within an
array. Now randomly generate a number between 0
and 100. Indicate whether user’s inputs include this
number, and its index if included. You should
ii l t mplement andd use ththe ff ll i ollowing methth dod iin your
program.
/ method /*method findElement() findElement() check check whether whether the the number number “target target”
exists in the array “numbers”. If so, return the index of
“target”; otherwise return -1.*/
public static int findElement(double target, double[] numbers);
Explanation / Answer
1 import java.util.Scanner; 2 class D9E1 { 3 public static void main(String[] args) { 4 double[] numbers; 5 int size; 6 Scanner scanner = new Scanner(System.in); 7 System.out.print("Enter the array size: "); 8 size = scanner.nextInt(); 9 numbers = new double[size]; 10 for (int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.