Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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      // ..     }   } }


  1. At time 't=0', in a kingdom there are 10,000 persons each having a wealth of 100 coins.
  2. At each time step 't=1,2,..', 2 randomly equally likely picked traders are trading.
  3. A person cannot trade with her/himself.
  4. A person has to have at least 1 coin to trade.
  5. 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 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals of Cost Accounting

Authors: William Lanen, Shannon Anderson, Michael Maher

3rd Edition

9780078025525, 9780077517359, 77517350, 978-0077398194

More Books

Students also viewed these Programming questions

Question

your ultimate goal upon graduation (i.e., career goals).

Answered: 1 week ago