I am working on a report in C# in which I am given a total number of prints a department printed and I have to distribute them according to the month date that on 1st March 10 papers are printed out and so on to 31st March.
I have a form which takes the total print outs count. I have a Month Selector.
From Month I get the total days which is total numbers to be generated eg: 30 or 31 or 28
Scenario :
In the month of March 2000 Prints outs Total Sum of Month : 2000 Numbers to be generated : 31
this is my code
int sum = 2345;
int nums = 23;
Random rand = new Random();
int newNum = 0;
int[] ar = new int[23];
for (int i = 0; i < nums; i++)
{
newNum = rand.Next(0, sum);
ar[i] = newNum;
sum = sum - newNum;
}
for (int i = 0; i < 23 ; i++)
{
Console.WriteLine(ar[i]);
}
Console.ReadLine();
what happens is in the ending numbers it goes to zero . I want Normally distributed like on one index it stores the maximum value at first and in the end it decreases.
We have a thrid party Ricoh Print/PhotoCopier Machine installed and third party bills us with certain amount which they have calculate that our department has printed 3000 printouts so we have to distribute them in the days randomly, print out the report and get payment invoice from our department head.
The department people are doing it on excel I offered them to give them a solution. Windows form application is built and I just have to put this logic thats all.. Thank you for your feedbacks