Another Simple Program

Another Simple Program - know that the person playing the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Discussion Questions on Algorithms and Compiling in Java due: discussion time on Tuesday 1. What is the output of the following algorithm? 1. Set num to 6. 2. Repeat while num > 0: 2a. print num 2b. set x to 3*num 2c. print x 2d. set num to num-1 2. What is the output of the following algorithm? 1. Set sum to 0. 2. Read an integer x from the user. 3. Repeat while x >= 0: 3a. Set sum to sum + x. 3b. Set x to x-1. 4. print sum. 3. Write an algorithm that reads a positive integer x from the user, and prints the square of x without using the multiplication operator. 4. Try your algorithm in #3 with at least 3 different values of x to check its accuracy. 5. Write an algorithm to play a simplified version of "20 Questions". In this version, you
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: know that the person playing the game has chosen one of the following things: dog, parakeet, horse, vacuum cleaner, screwdriver, tire iron. You can only use 3 yes/no questions to determine the chosen item. 6. In your own words and without looking at your textbook, class notes or any other source of information, describe briefly what is produced when you compile a java source program, and then how the resulting code is executed. 7. Without looking at any source of information, describe in your own words why Java is said to be platform-independent. 8. Do the following exercises in Section 1.12 of the online Stepp and Reges book: 2, 4, 5, 6, 12...
View Full Document

Ask a homework question - tutors are online