Please help me with the task: "One more calculator "

Hello, I’m working on this task:

Write a program that reads an integer count and a double number from the console. Then print the double number count times to the console, adding 1 to the number each time it prints. For example:

Here is my code:

namespace DoubleType
   class DoubleInLoops
       static void Main(string[] args)
       int count = int.Parse(Console.ReadLine());
       double number = double.Parse(Console.ReadLine()); 
       for(int i = 0; i < count; i++)
           Console.WriteLine(number + 1);

Can anyone please help me to solve it?

Hi Spydergirl1234, welcome to Codeasy!
In your code, I see that you print the same number to the screen. If we consider the example given in the task, your code will print 8.926 3 times.
To achieve the desired behavior I suggest you print the number, as it is:
and after that, change the number - assign number + 1 to it. In this case, the next time you output the number, it will be bigger.

Another way of solving this without changing the number is to add the index i to the number when you print it. It looks even more elegant :star_struck:

1 Like

That worked! Thank you so much for your help! :slight_smile:

1 Like