Write a program that performs a simple n-body simulation

Assignment Help C/C++ Programming
Reference no: EM13880939

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 gi 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, . . . ,n. In addition, the simulation also maintains, for each leprechaun, i, a place on the horizon, which is represented as a double-precision floating point number, xi. In 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 i, which is determined by the assignment xi?xi+rgi, whereris 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.

Reference no: EM13880939

Questions Cloud

Install the equipment necessary to start production : Dahlia Enterprises needs someone to supply it with 120,000 cartons of machine screws per year to support its manufacturing needs over the next five years, and you’ve decided to bid on the contract. It will cost you $870,000 to install the equipment n..
Types of political crime : In a well-constructed one page essay (500+ words), discuss the different types of political crimes of treason, espionage, and terrorism, and how the US fights these political crimes
How much do we expect sales to grow over the next year : Which of the explanatory variables in the regression are statistically significant? Explain. How much of the total variation in pie sales does the regression model explain?
Requires an initial fixed asset investment : Quad Enterprises is considering a new three-year expansion project that requires an initial fixed asset investment of $2.82 million. The fixed asset will be depreciated straight-line to zero over its three-year tax life, after which time it will be w..
Write a program that performs a simple n-body simulation : Write a program that performs a simple n-body simulation, called "Jumping Leprechauns." This simulation involves n leprechauns, numbered 1 to n.
What is cost of existing-new preferred stock respectively : A firm's preferred stock is selling for $27.50 a share. The firm nets $25.60 after issuance costs. The stock pays an annual dividend of $3.00 per share. What is the cost of existing, and new, preferred stock respectively?
Explain desired skills and how they relate to the classroom : Explain the desired skills and how they relate to the classroom and home
Calculate the differences in cost and risk : Explain with examples how the cost of capital is determined. Calculate the differences in cost and risk. Explain why the costs and risks of external financing are important for the organization to understand. Explain why rapid growth plans are import..
Mortgage loan to buy the home : You decide to take out a 30-year mortgage loan to buy the home of your dreams. The home purchase price is $1,000,000. You manage to scrape together a $200,000 down payment and plan to borrow the balance of the purchase price. If you sell your house i..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Implement the appropriate methods for big numbers

You must implement each big number as a List of single digits and you must also set up the template class List based on a linked list (use the sample codes). You will need to define and implement the appropriate methods for big numbers.

  Write a program with three functions

Write a program with three functions: upper, lower, and reverse.

  Program reads the contents of employees

Design a program that reads the contents of the employees.dat file and prints all the data within it. Format the report as designated in the Printer Spacing Chart below.

  Read integers values one at a time from standard input

Write a C++ program to do the following. The program will read integers values one at a time from standard input (cin) until you read the value 150.

  Mark the following statements as true or false

Mark the following statements as true or false.

  Compute and display net weekly pay

You need to prepare a C++ program in which you declare variables that holds an hourly wage, a number of hours worked, and a withholding percentage.

  Review a phonebook program

Add a command ‘d' for delete to delete an entry corresponding to a name typed by the user. Add a command "u" to allow a user to update (edit) one or more of the fields in the phonebook

  Print out contents of the vector

Write C++ program to provide the subsequent functionality - Ask users to enter 10 integer numbers and Print out contents of the vector.

  Write a program that reads in a list of integer numbers and

Write a program that reads in a list of integer numbers and print out the sum of all numbers, the average, the lowest and the highest value entered. The first input number indicates how many numbers the program is attempting to read. For example, if ..

  Guessing game

In C++ develop a "guessing game" where the computer and the user alternatively guess the value of a randomly selected secret number between 1 and 99 (or any other maximum value). Initially, the computer selects the random number, and the user make..

  Write the function - void shuffle

Write the function: void shuffle(int ar[], int size); This function "shuffles" the elements in the array pointed by 'ar' (and whose length is 'size').

  Design a program read the following information from the

design a program read the following information from the keyboard in which base class consist of employee name code and

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd