+ 1

4 of 5 results passed with Ballpark orders program

string order = Console.ReadLine(); string[] words = order.Split(' '); double cost = 0; foreach (var word in words) { if (word.Contains("Nachos") || word.Contains("Pizza")) { cost = cost + 6; } if (word.Contains("Cheeseburger")) { cost = cost + 10; } if (word.Contains("Water")) { cost = cost + 4; } if (word.Contains("Coke")) { cost = cost + 5; } if (!(word.Contains("Nachos") || word.Contains("Pizza") || word.Contains("Cheeseburger") || word.Contains("Water") || word.Contains("Coke"))) { cost = cost + 5; } } cost = cost * 1.07; Console.Write(cost);

6th Aug 2023, 11:41 AM
Simon
Simon - avatar
2 Respostas
+ 2
You may have to round the result to 2 decimal digits, even though it is not written explicitly by the task but suggested by the examples. Fractional cents don't make much sense, after all.
6th Aug 2023, 5:14 PM
Tibor Santa
Tibor Santa - avatar
0
Instead of sending in post, put code in code playground and send link
6th Aug 2023, 1:40 PM
Aaron Musisi
Aaron Musisi - avatar