+ 1

Can someone explain what I did wrong?

I tested the std::list with Ballpark order, but the elements doesn't add Up the the sum and only the first element's used. Sample Input: Water Water Water Output: ~4.28 I think the Problem's either with the std::list and how I gave them values or with the loop I Made to sum them(Through more likely First) https://code.sololearn.com/c73WEibmSJ7T/?ref=app

11th Jul 2022, 11:45 AM
Felix Alcor
Felix Alcor - avatar
3 Answers
+ 1
also, try to handl the case where the user enter a whitespace in the end of the string or a double space in between words like: 'Cheeseburger Water ' ^ ^ in this case ur prog will output another value different to what we expect.
11th Jul 2022, 12:52 PM
Amine Laaboudi
Amine Laaboudi - avatar
0
Hi Felix 👋 The std Library provides an input function called ws, which consumes whitespace from an input stream: std::getline(std::cin >> std::ws, input); use this instead of '' cin >> input;''
11th Jul 2022, 12:44 PM
Amine Laaboudi
Amine Laaboudi - avatar
0
Amine Laaboudi Thanks I found now all Problems and the Code seems to do his Work. 😆
11th Jul 2022, 1:22 PM
Felix Alcor
Felix Alcor - avatar