Answer to Question #183281 in C++ for Mridul

Question #183281

Radioactive decay of radioactive materials can be modeled by the equation A = A0e −t(log2/h) where A is amount of material at time t, A0 is the material at time 0, and h is the half-life of the radio active material. Technetium-99m is a radioisotope that is used in imaging of the brain. It has a half-life of 6 hours. Your program should display the relative amount of A/A0 in a patient body every hour for 24 hours after receiving the a dose. Prompt user for the initial dose (A0) in millicuries (mci). Typical values range from 3.8 - 15 millicuries. However, you can use any value for this program. Even milligrams. Enter values without negative exponents. If you want to enter 15 milligrams, enter 15. Same, for millicuries. 1Display your results in a table, the first column showing hours beginning at 0, and ending at 24. The second column shows the ratio of A/A0 beginning at hour 0 when the ratio is 1. Make sure that only positive values are entered for the initial dose using a do/while loop.


1
Expert's answer
2021-04-20T05:22:30-0400
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;


int main()
{
    const int h = 6;
    double A0;
    // checking the correctness of entering a positive number
    for (;;)
    {
        cout << "Enter a positive starting dose (A0): ";
        if ((cin >> A0).good() && (A0 > 0)) break;
        cout << "Invalid value entered, please re-enter" << endl;
        if (cin.fail())
        {
            cin.clear();
            cin.ignore(cin.rdbuf()->in_avail());
        }
     }
   //  ratio of A/A0 = e^(-t*log2/h)
    cout << "hours" << "     ratio  A/A0" << endl;
    // h = 0 
    cout << setw(5) <<0<< setw(16)<< 1 << endl;
    for (int t = 1; t < 25; t++) 
    {
        cout << setw(5) << t << setw(16) << exp(-t*log(2)/h) << endl;
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS