Homework 2

 

Due Monday, December 18 at Midnight

Permutations/Combinations (50 PTS) 1.  We are going to write a little program to enumerate the number of subsets of a set with particular properties.  Assume you have a set with n distinct objects.

- The number of different ways you can arrange all n objects in a line is n! or n factorial

n! = n(n-1)(n-2)(n-3) .... 1

 

- The number of different distinct subsets of size k is called combinations and is computed by

 

  1. Make sure you use at least one user defined method (different from the init( ) method).
  2. Make sure you get the inputs for n and k from the user.
  3. Make sure you give appropriate feedback to the user about what the combinations mean along with the appropriate inputs.

 

A Relatively Simple Calculator (50 PTS) 2. You need to create an integer calculator with

  1. Two textboxes  for user input.  One for a firstNumber, the other for a secondNumber so that the user knows where to place things to get results for firstNumber - secondNumber or firstNumber/secondNumber.
  2. A textbox that displays results.
  3. Four buttons with  +, -, *, / on them.

You DO NOT NEED to have parentheses or deal with complicated calculations.

A user should be able to put numbers into the textboxes and then press the button for what operation they want performed.   Then these two numbers will be used to perform the calculation and display the result in the third textbox.

You need the appropriate error trapping in case the user leaves entries blank or they are non-integer.

You need to write a separate method for each type of calculation.

I assume just doing this much will give you a sense of what would be involved in making it more realistic!