Task: Write a C++ program !

Nov 30, 2011 at 7:50pm
Dear everybody

I got the task to write a C++ program, but unfortunately as a newcomer, I have absolutely no idea in terms of the C++ programming language.

The task is as follows:
Write a Program to compute the Helmholtz free energy of gaseous carbon dioxide using Monte Carlo integration

---> for task formulations
see link
http://www.chemieonline.de/forum/attachment.php?attachmentid=24403&d=1322616647
and
http://www.chemieonline.de/forum/attachment.php?attachmentid=24404&d=1322616647

---> for given function rando
see link
http://www.chemieonline.de/forum/attachment.php?attachmentid=24405&d=1322616647

---> for references concerning equations (task formulation, in brackets)
see link
http://www.chemieonline.de/forum/attachment.php?attachmentid=24406&d=1322616647

It would be great if you could help me with this difficult task, I absolutely have no idea what to do!

code given:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*double rando (int &ig){
/* R. GEURTSEN, GRONINGEN, WFVG, JULY 1987 (Pascal VERSION) *
* REGULA WALSER, ZUERICH, JUNE 2000 (C++ VERSION) *
* *
* double rando (int &ig) *
* *
* RANDO GENERATES A RANDOM NUMBER RAND, USING A LINEAR *
* CONGRUENTIAL METHOD. THE RECURSION FORMULA *
* *
* IRAND = MOD(IRAND * B + 1, A) *
* *
* IS USED WITH B = 31415821 AND A = 100000000. THE LAST *
* DIGIT FROM THE RANDOM INTEGER IRAND IS CHOPPED OF, AND *
* THE NUMBER IS SCALED TO A REAL VALUE RAND BETWEEN 0 AND 1, *
* INCLUDING 0 BUT EXCLUDING 1. *
* *
* RETURN VALUE: DELIVERED WITH RANDOM NUMBER BETWEEN 0 AND 1 *
* IG: RANDOM NUMBER GENERATOR SEED, IS DELIVERED *
* WITH RANDOM INTEGER *
* */
const int m = 100000000;
const int m1 = 10000;
const int mult = 31415821;
int irand = abs(ig) % m;
// MULTIPLY IRAND BY MULT, BUT TAKE INTO ACCOUNT THAT OVERFLOW
// MUST BE DISCARDED, AND DO NOT GENERATE AN ERROR.
int irandh = int(irand / m1);
int irandl = irand % m1;
int multh = int(mult / m1);
int multl = mult % m1;
irand = ((irandh*multl+irandl*multh) % m1) * m1 + irandl*multl;
irand = (irand + 1) % m;
// CONVERT IRAND TO A REAL RANDOM NUMBER BETWEEN 0 AND 1.
double r = int(irand / 10) * 10.0;
r = r / m;
if ((r <= 0.0) || (r > 1.0))
r = 0.0;
ig = irand;
return r;
}
https://www1.ethz.ch/igc/education/Basic/exe/rando.cc
1*/
Topic archived. No new replies allowed.