Programming in pairs
General Steps:
- Do this in collaboration with your partner
- Do not start programming until you know how you plan to solve the problem
- Think about how you would do it. Try and come up with an idea
- Talk it over with your partner
- If you have an idea how to do this program, make sure that you can communicate your idea well enough for someone else to understand.
- Check this by having your partner state your idea back to you - did they understand it correctly?
- Now write the program. (Each person writes the program, but it will probably be the same program since it's the same idea or algorithm.)
- If you have two ideas on how to do this, then you could each try one.
Program: biggest 3 numbers
Assumptions:
- you know how to make an array
- you know how to make random numbers
Task:
- Make an array of 20 random ints.
- Find the biggest 3 ints
§ Does it make a difference in how you do your program whether the ints are from 0-100 or all possible values of int?
§ How much would need to be changed if you had 1000 random ints?
§ and if you had to find the top 15 numbers?
- Now change it to an array of positive doubles and see if it still works.
- Make sure that your doubles include large numbers, e.g. more than 10^7
(How do you get a random number that covers the whole range of doubles?
There are at least two ways to do this)