Cash register java using a random number generator and queue structure -
im trying make simulation of random number of customers going cash register. each cash register can hold 10 customers. during each random wave customer attended maximum of 5 lines.
random rand = new random(20041995); (int j = 0; j < 10; j++) { int pick = rand.nextint(10); system.out.println(pick); }
this rng i'm using , i'm trying integrate standard queue structure adds , deletes items in list.
this might point in right direction:
public static void main(string[] args) { random randomcustomer = new random(); list<integer> generatedcustomers = new arraylist<integer>(); //counter went 50 because each register holds 10 people for(int counter=1; counter<=50;counter++) { int customer = randomcustomer.nextint(20041995); //the random generated customers added generatedcustomers.add(customer); } //used sublist method once got size of array , split 5 parts (int start =0; start < generatedcustomers.size(); start += 10) { int end = math.min(start + 10, generatedcustomers.size()); list<integer> sublist = generatedcustomers.sublist(start, end); system.out.println("cash register" + " " + sublist); } }
}
my output generated this:
cash register [15365553, 2870686, 8239263, 490486, 10449085, 16420026, 3718359, 5010717, 2638567, 14760837] cash register [20040371, 16869399, 1942712, 14737317, 17357726, 4508897, 4992677, 5038990, 13511211, 8336697] cash register [4280460, 8933691, 3284599, 17767919, 16640768, 16720106, 2914768, 10021216, 576433, 14489405] cash register [10122975, 4817494, 18802466, 8706075, 6488663, 10421329, 13197130, 6107886, 7547101, 7711809] cash register [10627697, 9371901, 7711935, 15270912, 13733952, 12334688, 7676836, 4582069, 10586241, 11101172]
Comments
Post a Comment