Total the Prices
easyQuestion 272An array already holds a short list of prices: 4, 8, 15, 16, 23, and 42. Use a foreach loop to add every value together and print the grand total. A foreach loop is handy here because you only care about each value, not its position in the array, so you never have to manage an index yourself. Keep a total variable outside the loop and add each price to it.
Expected output
108= newline. The output ends with a newline, so print one after the last line.
Hints2 available
Sign in to use hintsTopics
Loops
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.