Problem 1: Write a method

public static boolean search(int[] a. int find)

that checks if a value entered by the user is found in a random array of 100 numbers from 0 - 100.

Write a program to test the method.

Display the following:

- The random array
- The search value and if the value was found in the array.

DO NOT use ArrayLists only standard arrays

Problem 2: The beachwear store is running a flash sale on many items. If a customer buys 3 or more discounted items, the customer receives a special on regular priced items.

The special is buy 2 get one free of the regular priced items. The free item is the lower-priced regular priced item.

Implement a method

public static void specialSale(double[] prices, boolean[] isSaleItem, int itemsEntered)

Your program will prompt for price and then prompt Y for sale item and N for regular priced items.

To finish input (sentinel value) user enters price as –1

The program will display the following at the end formatted with $ and 2 decimal places.

- How many sale items were purchased

- How many regular items were purchased

- How much the customer saved

- Total price

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class ArraySearch {

public static boolean search(int[] a, int find) {
boolean k = false;
for(int i = 0; i < a.length; i++) {
if(a[i] == find)
k = true;
return k;

public static void main(String[] args) {

// Generating the random array first
Random r = new Random();
int[] array = new int[100];
for(int i = 0; i < 100; i++) {
// r.nextInt((max - min) + 1) + min, where max = 100 and min = 0
int elem = r.nextInt(100 + 1);
array[i] = elem;

System.out.println("The random generated array is: ");
for(int i = 0; i < array.length; i++)
System.out.print(array[i] + " ");

$13.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats