Given three input variables:
- hotels - a list of hotel names
- ratings - their ratings in a city
- cutoff - the rating at which you would like to cut off
return only the names of those hotels with a rating of cutoff value or above as a column vector of strings good.
Solution Stats
Problem Comments
7 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers9311
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15782 Solvers
-
Calculate the Levenshtein distance between two strings
1507 Solvers
-
Are all the three given point in the same line?
601 Solvers
-
Sum of odd numbers in a matrix
617 Solvers
-
Given a square and a circle, please decide whether the square covers more area.
1725 Solvers
More from this Author13
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
You should mention that the answer should be given as a column vector, rather than row vector.
One at this time must examine the assessment code to give the right answer, while I think it should be self-contained in the question itself.
Thanks Richard. I have modified the problem description to mention this.
can anyone tell me the flaw in this code (im still very new to MATLAB)
function good = find_good_hotels(hotels,ratings,cutoff)
for c = 1:10 //the number 10 is a random number
if ratings(c) > cutoff | ratings(c) == cutoff
good = hotels(c);
else x = "not a good hotel"
end
end
@Kanishka, the question does not mention to return "not a good hotel", it only asks to return the names of hotels whose ratings is equalto or more than the threshold.
Good problem
very good and challenging problem
challenging