Jake

Jake

  • NA
  • 3
  • 985

Putting a random input into a DisplayDigits code.

Jan 29 2015 8:13 PM
            Console.WriteLine("Enter a number between 1 and 99999:");
            num = Console.ReadLine();
            DisplayDigits(num);
}
            public static void DisplayDigits(string num)
{
             for (int i = 0; i < num.Length; i++)
            Console.Write(num[i] + " ");
}
 
Current code . However I need it to run with a random integer value in the place so that it does not require input.
Here is my actual HW question.
 
c) Use the app pieces developed in parts (a) and (b) to write a method DisplayDigits that
receives an integer between 1 and 99999 and displays it as a sequence of digits, separating
each pair of digits by two spaces. For example, the integer 4562 should appear as:
4 5 6 2.
d) Incorporate the method developed in part (c) into an app that inputs an integer and
calls DisplayDigits by passing the method the integer entered. Display the results.