❔ Loop problem, beginner difficulty
Hi! I got stuck there and I'm run out of the ideas
Exercices:
Write a console application that calculates the sum of a given string of integers.
The numbers are entered one by one, and the application will read them one by one until the user writes the character x instead of a number. When the user has typed x the application knows that all the numbers in the string have been entered and displays their sum.
If the first thing the user types is the character x, the application will return 0.
Example:
For input data:
2
5
-3
1
x
The console will display:
5
6 Replies
What's the problem though? Where are you stuck?
File: Program.cs
Results:
Compilation completed successfully.
Test 1: The sum is correctly determined for the string of a number (3 x) - success
Test 2: The sum is correctly determined for the string of 2 numbers (3 2 x) - failed
Expected results: "5"
Results obtained: "2.5"
The submitted solution does not work correctly for a string consisting of two numbers.
I run it and I got these
Then first things first. You should check, what you are printing out in
Console.WriteLine
I solve it. Thanks for the help
I got a question? What is your code journey?
Code journey?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.