CS 1401, Exam #3, TR version

Date: Thursday, November 20, 2014
Name (please type legibly, ideally in block letters): ______________________________________________________________________

On November 20, 1985, Microsoft released its Windows 1.0 operating system. You may like Windows you may not, but it is the most widely used operating system.

1a. Write a method named increase that, given the total number of computers c using Windows in a certain year and the number of computers f using it in the following year, returns the percentage with which this number increased.

For those who may have forgotten what a percent is:

1b. In the main method, call your method increase to compute the percentage increase from 1,000 to 1,500; the result should be 50%.

1c. Trace, step-by-step, how the computer will perform all the needed computations, and check that the result is indeed correct.
































2a. Define a class OperSystem whose objects are different operating systems. The description of each operating system should contain its name, the year when it was released, and the number of computers using this system. Your class should contain a constructor method, get- and set-methods, and a method that, given a current year, returns the age of the given operating system.

2b. Use your class in the main method to define a new object windows of type OperSystem describing Windows 1.0, which was released in 1985 and now has 0 users. Compute and print the age of this system. Then, change the values corresponding to this object to Windows 7 which was released in 2009 and which now has 630 million users. Compute and print the new age.

2c. Trace your program step-by-step.












































3a. Which operating system is the most widely used? To answer this question, write a method that, given an array u of number of users using an operating systems and an array n of their names, returns the name of the most widely used operating system.

3b. To check the correctness of your method, test it on the example of two arrays: array opSystems with elements "Windows 7", "Windows 8", and "Linux", and array users with values 630 million, 40 million, and 100 million.

3c. Trace step-by-step how the piece of code you wrote in Part 3b finds the name of the most widely used operating system.
















































4a. Advertisers pay a certain amount for each user. Write a method that, given an array of numbers of users of different operating systems and a payment-per-user value, returns a new array with the amounts given to the owner of each operating system.

4b. To check the correctness of your method, test it in the main program on the example of an array u consisting of 630 million and 40 million users, and a payment of 0.1 cent per user.

4c. Trace step-by-step what happens when you run the piece of code you wrote in Part 4b. The result should be an array consisting of values $630,000 and $40,000.


















































5. Describe the main teamwork roles, and what are the main tasks of the corresponding persons.



























































6. Describe what is white-box testing and what is black-box testing. Describe the main rules for testing; give an example for each rule.