Hands-on 7b Hints

Nuclear Valley of stability

Reading nuclei data in steps

In this exercise we will adapt our program readIsotope.cxx and make it reading the new nuclei.txt file containing the data of known nuclei. You have to adapt the code to take into account the new data structure and the new class, Nucleus.

During code development you can use the nuclei_small.txt data file which contains a fraction of all data. When your program reads the data ok you can test with the big nuclei.txt file.

Note, that the input stream operator for the Nucleus class is not provided and so you need to read the data in local variables first and then use the class “set” functions to save them in the Nucleus objects.


  1. Copy the code in the body of main() function from readIsotope.cxx in readNuclei.cxx

  2. Change the filename value to nuclei_small.txt

  3. Use your editor Find&Replace function and change the strings isotope, isotopes, Isotope into nucleus, nuclei, Nucleus respectively.

  4. Change the variables after the comment // Define variables to hold data to correspond to the data in the provided file. Define them in the same order as they appear in the file.


    • Use the string type to read half-life values
  5. Change the line after the comment // Read data of one nucleus to read all the data for one nucleus

  6. Adapt the code after the comment // Define Nucleus object and use the Nucleus class setters to fill in read data into the Nucleus object.