Question: Write a method called priceIsRight that mimics the guessing rules from the game show The Price Is Right. The method accepts as parameters an array

Write a method called priceIsRight that mimics the guessing rules from the game show The Price Is Right. The method accepts as parameters an array of integers representing the contestants’ bids and an integer representing a correct price. The method returns the element in the bids array that is closest in value to the correct price without being larger than that price. For example, if an array called bids stores the values [ 200, 300, 250, 1, 950, 40 ] , the call of priceIsRight(bids, 280) should return 250 , since 250 is the bid closest to 280 without going over 280. If all bids are larger than the correct price, your method should return –1.

Step by Step Solution

3.43 Rating (166 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public static int priceIsRight int bids int price int bestPrice ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!