This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 15100 RECITATION 6  FALL 2007Introduction Integers can be stored in a computer using 8bits (a byte), 16bits (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 8bit 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 8bit 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
 Fall '07
 TOM
 Binary numeral system, Power of two

Click to edit the document details