InLab05 Solution

# InLab05 Solution - System.out.print"Enter a...

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

Sheet1 Page 1 // Solution to In-lab assignment #5 import java.util.Scanner public class InLab05 { public static void main(String[] args) { // Standard set #1 int[] month = {9, 10, 10, 11, 11} int[] day = {3, 22, 23, 22, 23} String[] holiday = {"Labor Day", "Fall Break", "Fall Break", "Thanksgiving", "Thanksgiving"} for (int i = 0 System.out.println(month[i] + "/" + day[i] + ":\t" + holiday[i]) // Standard set #2 int[] powersOf3 = new int[10] for (int i = 0 powersOf3[i] = (int) Math.pow(3, i) } Scanner scanner = new Scanner(System.in)

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: System.out.print("Enter a number: ") int guess = scanner.nextInt() int index = BinarySearch.binarySearch(powersOf3, guess) if (guess > powersOf3[powersOf3.length - 1]) System.out.println("I cannot evaluate numbers that large.") else if (index < 0) System.out.println("That is not a power of 3.") else System.out.println("That is 3 to the power " + index + ".") } } Sheet1 Page 2 i < holiday.length i++) i < powersOf3.length i++) {...
View Full Document

## This note was uploaded on 04/10/2008 for the course ENGR 131 taught by Professor Xiaowei during the Spring '07 term at Case Western.

### Page1 / 2

InLab05 Solution - System.out.print"Enter a...

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

View Full Document
Ask a homework question - tutors are online