Lab 2
(14-1-2002 to 17-1-2002)

1. Older computers used Binary Coded Decimals (BCD) to represent integers. In this each digit is represented by using 4 bits. So 0 is 0000, 1 is 0001, 2 is 0010, ... 9 is 1001. The remaining 4 bit patterns, namely 1010 onwards are illegal. So 32 bits can store upto 8 digits. To represent a negative number the sign is also encoded using 4 bits. However, we are interested only in positive BCD numbers. For example assuming we have 32 bits the number 123 will be represented as (0000) 5 times followed by 000100100011.

Define a class BCD with a single constructor which takes an int argument and creates its BCD equivalent. Write methods for adding, subtracting, multiplying and dividing BCD numbers. Also, write methods to check for <, > and == between two BCD numbers.

[15]
2. Write a class Convert with static methods as follows:
    a) takes 4  arguments representing miles, yards, feet and inches and converts them into kilometers, meters and centimeters.
    b) takes an argument representing degrees Farenheit and converts it to degrees centrigrade.
    c) a kilobyte is interpreted in two ways: some times it is 1000 bytes (actually correct), but often (and traditionally) it is 210 which is 1024. Similar discrepancies arise for mega, giga, tera and peta (each is 1000 (or 210 ) times the previous one).
The function should take the 103 (standard kilo) and give the equivalent value using  210 as a kilo for all the above.
[10]