Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help making a counting program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need help making a counting program

    So my professor told me to make a General purpose counting program for him using C# (Console Application)

    This is the program specification: Design, write and test a program to display any list of numbers, given the starting number (lower limit), the final number (upper limit) and the step size. Eg. 0,2,4,6,8 (LowerLimit = 0, Upperlimit = 8, StepSize = 2)

    I wrote pseudo code for it:
    1. Set up variables to store the 3 numbers and the loop counter
    2. Store the lower limit entered by the user
    3. Store the upper limit entered by the user
    4. Store the step size entered by the user
    5. Repeat the following, starting at lower limit, and going up to upper limit in steps of stepsize
    6. Display the counter
    7. End of loop

    I am struggling to translate step 5 into C# code.

    This is what I have done so far:-


    Code:
    class Program { public static Single lowerLimit, upperLimit, stepSizes, counter, upperScaler; static void Main(string[] args) { Console.WriteLine("Enter the lower limit "); lowerLimit = Convert.ToSingle(Console.ReadLine()); Console.WriteLine("Enter the upper limit "); upperLimit = Convert.ToSingle(Console.ReadLine()); Console.WriteLine("Enter the step sizes "); stepSizes = Convert.ToSingle(Console.ReadLine()); Console.Clear(); for (counter = lowerLimit; counter <= upperScaler; counter++) { Console.WriteLine(counter * stepSizes); if (counter != 1) { upperScaler = upperLimit / stepSizes; } } Console.ReadLine(); } }
    MyBKExperience MyWMTotalRewards




    Any help will be greatly appreciated.
    Last edited by harrycharlesop; 08-21-2020, 05:50 AM.

    #2
    Hello harrycharlesop,

    Welcome to the NinjaTrader support forum.

    This forum is generally used for NinjaTrader related questions, it seems this is a general C# question and does not seem to relate to NinjaTrader or NinjaScript. For this type of question on a general C# topic you will likely find more help or more specific answers using stackoverflow or google. https://stackoverflow.com/questions/tagged/c%23

    You may try searching for "C# increment counter" as one example, or "C# increment counter in a loop". There are many existing guides for various C# tasks posted in various locations online. Using the WriteLine would be a good way to understand your code and see what is being output to understand what to do next.

    You may also want to work with your professor directly to see if there was a specific concept they were trying to teach, if so you could try to search online for that concept.

    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      okay thanks for the response

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bortz, 11-06-2023, 08:04 AM
      47 responses
      1,603 views
      0 likes
      Last Post aligator  
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      8 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      4 views
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      12 views
      0 likes
      Last Post Javierw.ok  
      Working...
      X