Session 2

Examen 2021-2022 - Session 2

Part A:test

Getting start code - Part B

Start code: examen_code.tar.gz

Download the start code, upack it and copy the top directory examen_code in a new directory, named examen_YourFamilyName. You should develop your solutions in this new directory.

cd 
tar xzvf examen_code.tar.gz
cp -r examen_code examen_YourFamilyName
cd examen_YourFamilyName

Task 1: testFunctions

The given code in the testFunctions.cxx program is buggy (it does not compile). Correct the compilation errors and then test the program.

There is no need to modify the code in the myFunctions.h and myFunctions.cxx files.

Task 2: sphere

The purpose of the sphere.cxx program is to compute the mass of a sphere with the dimensions defined by the user for three given materials.

Assignment 1:

Ask the user for a radius of sphere

Assignment 2:

Check that the read value represents a real cylinder:

   radius > 0

If this condition is not satisfied, report it and abort the program.

Assignment 3:

Compute and display the volume of the cylinder:

   volume = 4 / 3 * PI * radius * radius * radius
Assignment 4:

Compute the mass of the cylinder for the defined materials and print the results:

   mass = volume * density

Task 3: nuclei

The program processNuclei.cxx already contains a vector filled with a number of nucleus objects which properties are defined in the provided class Nucleus.

A sample code, how to process all vector elements and print the selected nuclei data, is provided below the vector definition.

Your task is to add the code that will find the nucleus with the highest half-life and print its symbol, Z, A and this halflife.

There is no need to modify the code in the Nucleus.h and Nucleus.cxx files.

Solution: