Assignment1 - For example, these numbers should work: 8646...

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

View Full Document Right Arrow Icon
Assignment #1 Due Date: Saturday, January 19 at 11:55pm Submit: WebCT Late Policy: -1 point per minute late Instructions: This is an individual assignment. Answers should be your own work. Chapter 1 20 points 1) Prove by induction ( note: replace "sum" with the sigma summation symbol in the formula below ) n n n sum (i*i*i) = ( sum i ) * ( sum i ) i=0 i=0 i=0 20 points 2) Write a program that has a recursive method named "log2" having an integer argument called num. Your recursive method should determine the log base 2 of num rounded down to the nearest integer. So, 8 should return 3, 9 should return 3, and 16 should return 4. Your method should return an integer. Your program should prompt the user for a number and then print the result. 20 points 3) Write a program that has a recursive method named "checkdigits" having an integer argument called num. Your recursive method should determine whether every digit in num is followed by a digit that is either +2 or -2 in value from its prior digit.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: For example, these numbers should work: 8646 97535 13531, and these should not: 862, 971, 134. Your method should return a boolean. Single-digit numbers should return false. Your program should prompt the user for a number and then print true or false. 40 points 4) Write a generic class called Trio that has one type parameter. It contains three items, each being of the type parameter's type. It contains three methods, first() and second(), and third(), that return one of the three items respectively. Include a main method in the class which creates a Trio object with a String type. The object should be created with three strings: "abc", "def", "ghi". Use the first(), second(), and third() methods to get each string from the Trio object and print it. Submit to WebCT. Please give the files you submit meaningful names. If necessary, include a "readme" file that describes your submission. Problem 1 can be a text file, while problems 2-4 should be source files....
View Full Document

This note was uploaded on 04/07/2008 for the course CS 3345 taught by Professor Ozbirn during the Spring '08 term at University of Texas at Dallas, Richardson.

Page1 / 2

Assignment1 - For example, these numbers should work: 8646...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online