Exercise · Strings · lesson 4 of 12
Exercise: order line
Write a function function formatOrder(item, price, count) that returns an order line of the form "<count> x <item> = <total>", where the total is price * count. There is exactly one space between the parts, and x is the small Latin letter.
formatOrder("tea", 50, 3)→"3 x tea = 150"formatOrder("green tea", 70, 1)→"1 x green tea = 70"formatOrder("cake", 120, 0)→"0 x cake = 0"
Constraints: item is a non-empty string of Latin or Russian letters and spaces, price and count are whole numbers from 0 to 1000; if price or count is 0, the total is 0.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.