Thursday, October 20, 2011

random rekening bank dalam c#.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("masukan jumlah rekening");
            int a = int.Parse(Console.ReadLine());
            Random r = new Random();
            int i = 1;
            while (i <= (a))
            {
                int j = 1;
                while (j <= 8)
                {
                    int w = r.Next(100);
                    if (w == 0)
                    {
                        Console.Write("00");
                    }
                    if (w<=9)
                    {

                        if (w > 0)
                        {
                            Console.Write("0{0}",w);
                        }
                    }
                    if (w > 9)
                    {
                        Console.Write("{0}", w);
                    }
                    if ((j - (j / 2) * 2) == 0)
                    {
                        if (j < 8)
                        {
                            Console.Write("-");
                        }
                    }
                    j = j + 1;
                }
                Console.WriteLine("");
                i = (i + 1);
            }

        }
    }
}

No comments:

Post a Comment