Buy sweets with an iterator

Report a typo

You have a shopping cart with sweets – it should be presented as Map<String, Integer>, where the key is the name of a sweet and the value is its price. You should fill Map<String, Integer> from console and then count the total cost of the shopping cart.

Firstly, you get the number of sweets in the cart; then, you get their names and prices.

Sample Input 1:

3
choco 10
cake 50
marmelade 25

Sample Output 1:

85
Write a program in Kotlin
fun countSum(sweets: Map<String, Int>): Int {
// write your code
}

fun main() {
var cart = mutableMapOf<String, Int>()
// write your code
println(countSum(cart)) // do not change this line
}
___

Create a free account to access the full topic