Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

Students also viewed these Databases questions

Question

Explain Intermediate term financing in detail.

Answered: 1 week ago

Question

Types of cultural maps ?

Answered: 1 week ago

Question

Discuss the various types of leasing.

Answered: 1 week ago

Question

Define the term "Leasing"

Answered: 1 week ago

Question

=+management system of the MNE?

Answered: 1 week ago