Reading the Input Data

Before we proceed to the reading of the input data, we must declare the variables, in which we will store them. This means choosing the right type of data and appropriate names.

In the variable n we will store the count of numbers, which we will read from the console. We choose int type, because in the description is said, that n is integer number within the range from 1 to 1000. For the variables, in which we will store the percentages, we choose double type, because they are not expected to be always integer numbers . Additionally, we declare the variables cntP1, cntP2 etc., in which we will keep count of the numbers from the respective group, and we choose again int type.

After we have declared the needed variables, we can read the number n from the console:

results matching ""

    No results matching ""