Question
This question has been posted but the answer given on this site leaves an error when compiling No suitable method found for println(java.lang.String,) My question
This question has been posted but the answer given on this site leaves an error when compiling "No suitable method found for println(java.lang.String,)
My question is for Java as follows. Create a program that has an array of length 100 which will automatically be filled with randomly generated numbers between 1 and 100 each time the program is run. Have the program ask the user to enter a number between 1 and 100. Check to see if that number is one of the values in the array. If it is display We found your number XX at position YY in the array If the number is not in the array tell the user that no match was found.
The following is what I have so far, please advise what needs corrected to make this work for Java
import java.util.*; import java.lang.*; import java.io.*;
class Search { public static void main (String[] args) throws java.lang.Exception {
int[] array; for (int i = 0; i < 100; i++) { array[i] = 1 + (int)(Math.random() * 100); } Scanner sc=new Scanner(System.in); System.out.println("Enter number between 1 and 100"); int number=sc.nextInt(); for (int i = 0; i < 100; i++) { if (array[i] == number) { System.out.println("We found your number " , number, " at position ", i, " in the array"); } else { System.out.println("no match was found"); break; } } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started