{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

recitation6

# recitation6 - 15-100 RECITATION 6 FALL 2007Introduction...

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 15-100 RECITATION 6 - FALL 2007Introduction Integers can be stored in a computer using 8-bits (a byte), 16-bits (a word), and larger sizes to accommodate larger ranges of numbers. In this exercise, you will use an array to store powers of 2 in an array. Then you will ask the user to input an 8-bit number in binary and you will use the array to compute its value. Exercise Write a Java program using Eclipse that performs the follow steps. 1. Create an array with the following powers of two: 0 1 2 3 4 5 6 7 ----------------------------------------------- | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | ----------------------------------------------- Try to create this array using a loop that initializes each value based on the previous value in the array, starting from the last cell of the array. You'll need to set the first value directly. Do not use Math.powhere. 2. Ask the user for an 8-bit binary number (a number containing only 0s and 1s). Read this as a String. You may assume the input contains only 0s and 1s. But if the user does this as a String....
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

recitation6 - 15-100 RECITATION 6 FALL 2007Introduction...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online