id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-lists > apcsaListPricedRight
prev  |  next  |  chance

Given an ArrayList of names, an ArrayList of price guesses and an actual price, find and return the name of the person who guessed closest to the actual price without going over it. If everyone went over, return an empty String. Precondition: no two guesses will be the same value, and the two ArrayLists will have the same size.


apcsaListPricedRight(["Jett", "Lisa", "Kessie"], [53, 23, 100], 101) → "Kessie"
apcsaListPricedRight(["Jeron", "Abel", "Maggie"], [23, 24, 22], 26) → "Abel"
apcsaListPricedRight(["Anna", "Olaf", "Elsa"], [1000, 10000, 100000], 50) → ""

...Save, Compile, Run (ctrl-enter)

public String apcsaListPricedRight(ArrayList<String> names, ArrayList<Integer> guesses, int price) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 220

Copyright Nick Parlante 2017 - privacy