Question: Java: If we have one hashmap, each key is one kind of bread name, each value is this bread price. such as {sh - 15,
Java: If we have one hashmap, each key is one kind of bread name, each value is this bread price. such as {sh - 15, bd -17, be -17, ar -50}
now we should print all bread are listed in ascending order by price. Also, if we have same price bread, print listed alphabetically. NO nested loop!no line over 80 columns! Use test case one - fourteen.
so output: sh: 15
bd: 17
be :17
ar :50
test:
input:
| eight -$35 | |
| eleven - $496 | |
| five - $490 | |
| four - $111 | |
| fourteen - $507 | |
| nine - $658 | |
| one - $81 | |
| seven - $1320 | |
| six - $294 | |
| ten - $329 | |
| thirteen - $120 | |
| three - $496 | |
| twelve - $392 | |
| two - $890 |
output:
| eight : $35 | |
| one : $81 | |
| four : $111 | |
| thirteen : $120 | |
| six : $294 | |
| ten : $329 | |
| twelve : $392 | |
| five : $490 | |
| eleven : $496 | |
| three : $496 | |
| fourteen : $507 | |
| nine : $658 | |
| two : $890 | |
| seven : $1320 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
