The assignment requires you to create 10,000 persons named 'i j' with wealth of 100 coins each.
Question:
The assignment requires you to create 10,000 persons named 'i j' with wealth of 100 coins each. Then, simulate trading of 10,000 persons in some kingdom for 1,000,000 trades. Following has to be satisfied:
package projecteg4; public class ProjectEG4 { public static void main(String[] args) { // Create 10,000 persons named 'i j' with wealth of 100 coins each. person P[][] = new person[100][100]; for(int i = 0; i < 100; i++) { for(int j = 0; j < 100; j++) { P[i][j] = new person( String.valueOf(i) + " " + String.valueOf(j), 100f); } } // Simulate trading of 10,000 persons in some kingdom for 1,000,000 trades: // At each time step 't=1,2,..', 2 randomly equally likely picked traders are trading. // Person cannot trade with her/him self. // Person has to have at least 1 coin to trade. // One of them makes 1 coin with 50% chance and the other loses 1 coin with 50% chance. java.util.Random rnd = new java.util.Random(); person p1, p2; for(int i = 0; i < 1000000; i++) { // pick 2 different persons each with more than 0 coins so they can trade // .. // let 2 persons trade and update their wealth // .. } } }
- At time 't=0', in a kingdom there are 10,000 persons each having a wealth of 100 coins.
- At each time step 't=1,2,..', 2 randomly equally likely picked traders are trading.
- A person cannot trade with her/himself.
- A person has to have at least 1 coin to trade.
- One of the 2 persons makes 1 coin with 50% chance and the other loses 1 coin with 50% chance.
Fundamentals of Cost Accounting
ISBN: 978-0077398194
3rd Edition
Authors: William Lanen, Shannon Anderson, Michael Maher