Generate a sub/function to simulate the roll of a single die. It
should return a random number
between 1 and the maximum number of faces on that die. Allow the
user to specify different
number of
faces.
20 pts
Generate a sub/function to determine the number of years it takes to double your money if you invest it, given a user specified interest rate. See attached spread sheet for examples. 20 pts
Example results (starting at $1)
1.5% 48 yrs $2.013
2.0% 37 yrs $2.040 (36 years gives you $1.99989)
2.5% 30 yrs $2.046
FIRST QUESTION.
#include<bits/stdc++.h>
using namespace std;
int main()
{
srand(time(0));
int x;
cout<<"\nEnter the number of faces : ";
cin>>x;
if(x < 1)
{
cout<<"\nIncorrect input.";
exit(0);
}
int val = 1 + rand() % x;
cout<<"\nResult is : "<<val;
}
SECOND QUESTION
In Compound interest the formula for resulting amount is A = P * (1 + r/n)^(nt)
A = Amount
P = Principal value
r = Interest rate
n = No. of times compounded in a year,
t = time
***For amount to be doubled, A = 2P and in this case n = 1 as it is compounded annually.
CODE
#include<bits/stdc++.h>
using namespace std;
int main()
{
double rate;
cout<<"\nEnter the interest rate in % : ";
cin>>rate;
double P=1.0;
//Formula is A = P * (1 + r/n)^(n*t)
//n = 1; A = 2P;
//double time = 72.0 / rate;
double time = log(2.0) / log(1.00 + 0.01 * rate);
double x = P * ( 1.0 + (0.01 * rate));
double val = pow(x,time);
if(val < 2.0000005) //2.0000005 To compensate for the error.
{
time++;
}
cout<<"\nTime taken is : "<<ceil(time);
}
NOTE - For any other query, Pls use the comment section
Generate a sub/function to simulate the roll of a single die. It should return a random...
III. Overview & Requirements:
The following description has been adopted from Deitel &
Deitel. One of the most popular games of chance is a dice game
called "craps," which is played in casinos and back alleys
throughout the world. The rules of the game are
straightforward:
A player rolls two dice. Each die has six faces. These faces
contain 1, 2, 3, 4, 5, and 6 spots. After the dice have come to
rest, the sum of the spots on...
I need Summary of this Paper i dont need long summary i need
What methodology they used , what is the purpose of this paper and
some conclusions and contributes of this paper. I need this for my
Finishing Project so i need this ASAP please ( IN 1-2-3 HOURS
PLEASE !!!)
Budgetary Policy and Economic Growth Errol D'Souza The share of capital expenditures in government expenditures has been slipping and the tax reforms have not yet improved the income...