Using the Runge-Kutta method, display a table of the fraction of a radioactive material left after a certain number of years of decay. Also display the exact values using the solution y=e^(-cx)

What will be an ideal response?


```
int main()
{
double halflife;
int years, inc;

cout << endl << "Please enter the half-life of the radiocative material => ";
cin >> halflife;
cout << endl << "Please enter the number of years of decay to display => ";
cin >> years;
cout << endl << "Please enter the year increment to display => ";
cin >> inc;

cout << endl << "Fraction of Radioactive Material Left" << endl
<< endl << "Years" << setw(10) << "Approx" << setw(10)
<< "Exact" << endl << "-------------------------" << endl;

double material = 1.0;
for (int i = 0; i < = years; I += inc) {
for (int j = 0; (j < 10 * inc && I > 0); ++j)
// calculate 10 times per year
material = rungekutta(material, halflife);
cout << setw(5) << i << setiosflags(ios::showpoint|ios::fixed)
<< setprecision(4) << setw(10) << material
<< setw(10) << f(i, halflife) << endl;
}

cout << endl;

return 0;
}

```

Computer Science & Information Technology

You might also like to view...

You resize a table the same way you resize ____.

A. a chart B. a SmartArt graphic C. any graphical object D. a document

Computer Science & Information Technology

A user can add ________ to the criteria for a field in the design grid to return results where there is nothing in that field

A) Is Empty B) Is Null C) Is Not Null D) Is Not Empty

Computer Science & Information Technology

You can assign to a variable literal strings, numeric values, or the value of another variable.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A system administrator is selecting an operating system for use by the company’s research and development team. The team requires an OS that can be easily modified and changed to meet its particular requirements.   Which of the following operating systems will be the best choice for the users?

A. Windows 10 Enterprise B. Mac OS X C. Linux D. Windows 7 Professional

Computer Science & Information Technology