Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

HELP, HELP, HELP PLEASE



please help me with this home work assignment



question 1

write a proram that converts a binary to decimal



question 2

write a program that converts a decimal number to binary



question 3

A parking lot registers the time that a car arrives at the lot (like 8:25) and the time that the car leaves the lot (like 14:55). Write a program that would read the 2 times from a DATA statement and calculate the length of time, in hours and minutes that the car had been in the lot.



Jordan Patel




Comments

  • Normally, I don't help with homework assignments, but I think I can point you in the right direction without completely giving it away.



    Regarding binary number format: Starting at the right hand side, each digit is the equivalent of 2 raised to the power of 1 less than the digits position from the right.

    (ALWAYS FROM THE RIGHT!)Take position 1 for example: The position's value is equal to 2 ^ (1 - 1) = 2 ^ 0 = 1. Position 2: 2 ^ 1 = 2. 2 ^ 2 = 4. 2 ^ 3 = 8. If the digit is a 1, then you need to add it's value.

    11111 = 2 ^ 4 + 2 ^ 3 + 2 ^ 2 + 2 ^ 1 + 2 ^ 0 = 16 + 8 + 4 + 2 + 1 = 31

    11000 = 2 ^ 4 + 2 ^ 3 = 16 + 8 = 24

    To convert back, simple keep subtracting the highest power of 2 that you can until you reach 0.

    23 ? 2 ^ 5. 23 < 32. 0

    23 ? 2 ^ 4. 23 > 16. 23 - 16 = 9. 1

    9 ? 2 ^ 3. 9 > 8. 9 - 8 = 1. 1

    1 ? 2 ^ 2. 1 < 4. 0

    1 ? 2 ^ 1. 1 < 2. 0

    1 ? 2 ^ 0. 1 = 1. 1 - 1 = 0. 1

    Binary: 11001



    Hope this helps!


Sign In or Register to comment.