Reading the Input Data

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

In the variable n we will store the count of numbers that we will read from the console. We choose int type, because in the description it say, that n is an integer 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 always be integers. Additionally, we declare the variables cntP1, cntP2 etc., in which we will keep the 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 ""