Can somebody help me with this? I need to know how to do this in C++ Write a pro
ID: 3697991 • Letter: C
Question
Can somebody help me with this? I need to know how to do this in C++
Write a program that performs a simple n-body simulation, called "Jumping Leprechauns." This simulation involves n leprechauns, numbered 1 to n. It maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, gi = 1000000 for each i = 1, 2,. ..,rc. In addition, the simulation also maintains, for each leprechaun,/, a place on the horizon, which is represented as a double-precision floating point number, xIn each iteration of the simulation, the simulation processes the leprechauns in order. Processing a leprechaun i during this iteration begins by computing a new place on the horizon for/, which is determined by the assignment Xi leftarrow X_i + rg_i, where r is a random floating-point number between - 1 and 1. The leprechaun i then steals half the gold from the nearest leprechauns on either side of him and adds this gold to his gold value, gi. Write a program that can perform a series of iterations in this simulation for a given number, n, of leprechauns. You must maintain the set of horizon positions using an ordered map data structure described in this chapter.Explanation / Answer
public void addCustomer(Customer newCust) {
this.customers.put(newCust.getName(), newCust);
}
public void addCustomer(String name, int initpwd) {
this.customers.put(name, new Customer(name, initpwd));
}
public void addCustomer(String name, Customer newCust) {
this.customers.put(name, newCust);
}
}
class AcctSetHM implements IAccountSet {
private HashMap<Integer,Account> accounts =
new HashMap<Integer,Account>();
public Account findByNum(int num) {
return accounts.get(num);
}
}
public void addCustomer(Customer newCust) {
this.customers.put(newCust.getName(), newCust);
}
public void addCustomer(String name, int initpwd) {
this.customers.put(name, new Customer(name, initpwd));
}
public void addCustomer(String name, Customer newCust) {
this.customers.put(name, newCust);
}