At TC University, there are a number of different majors. People in these
majors occasionally switch from one major to another each year. Additionally,
TCU is famous for having students who never graduate. Your task is, given a
list of majors, the starting number of people in each major, and the
percentages of people who switch from each major to each other major,
determine the expected number of people who are in each major after a certain
number of years.
The input String[] will be a list of the
percentages of people who change to each other major, each year. Element i of percentages is a single space delimited list of integers, where the jth integer in the list represents the percentage of people in major i who switch to major j each year (the ith integer in element i is the percentage of people in major i who stay in that major). You will also be given a int[], start representing the intial number of students in each major (the ith element of start represents the number of people starting in major i).
Thus, if the input String[] were {"90 10","05 95"} this would mean that each
year 10% of the people with major 0 become people with major 1, while the
remaining 90% keep major 0. Similarly, every year 5% of people with major 1
switch to major 0, while the other 95% of them remain in major 1.
If a fractional number of people would switch majors, add the fractional part onto the number of people who remain in the same major they started in. Thus there are always the same number of total people at TCU. For example, if you end up with 4.7 people switching from one major 0 to major 1, and 3.3 people staying in major 0, then take the 0.7 people, and add them to the number of people who stay in the same major. Thus, in this example, 4 people would switch from major 0 to major 1, and 4 people would stay in the major 0.
Given this information, and the number of years that people are switching,
determine how many people there are in each major after the given number of years have passed.
|