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
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.
Step by Step Solution
3.55 Rating (141 Votes )
There are 3 Steps involved in it
Step: 1
Answer To fulfill the requirements of the assignment you can create a Person class and a main class ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started