By Thanos Stantzouris
Choose your prefered Language: greek_flag uk_flag

The moment of inertia of a solid body consisting of NN number of material points 𝑃𝑖, i = 1,2, ...,𝑁 with a corresponding mass π‘š, with respect to the levels xOy, yOz, zOx, are calculated according to the following formulas:

ΙχΟy = Σmizi2 , ΙyOz = Σmixi2 , ΙzOχ = Σmiyi2

Write a class named inertia that will handle the data needed to calculate the corresponding momentum inertia of a solid body. The members of the private class will be:
    1. The three coordinates (double)
    2. The corresponding mass of a material point of the solid body (double)
    3. The code of the solid body (int).

An array of objects of the inertia class with N positions (N = known and N > 100) contains data that can belong to 10 (the most) different solid bodies with corresponding codes from 0 to 9.

The requirements are as follows:

    1. Each element in the array (object of the inertia class) should be initialized with null values ​​using a constructor function.

    2. Each element in the array should have handled values ​​(all coordinates are positive or zero and the mass must be a positive number) using random numbers (rand() function with upper limits to be specified by you), using the appropriate constructor.

    3. In the main() function, the inertia moments χOy, yOz, zOx for each solid body present in the object array are calculated and displayed, provided that each solid body has at least 5 material points.