CSCI A201/A597 and I210

Practical Exam Practice Problems

Second semester 2000-2001

Information about the practical exam.

I am going to post here types of problems.

And the solutions will be posted here.
I will update this page as often I can. I won't be posting solutions, but I may work out some on-line (in class). I might be posting sample sessions with the programs, for you to get a better idea of how the program should interact with the user.

  1. Write a program that greets the user, then asks the user for a positive number. This number is to be used as the size of an array of prices that the user is going to enter. Then the programs asks the user to enter the prices, one by one. Each price is to be entered on a line of its own. Have the computer keep track of how many prices are being entered and how many are still to be entered at any time. Then, at the end, the computer prints the largest price, the smallest price, and the average of all the prices entered.

  2. Same, except output is the standard deviation of the prices entered. Use the formulas in problem P6.9 in the text (page 265).

  3. Write a program that asks the user how many Fibonacci numbers (see page 264, problem P6.7 in the text) it should compute. Then produce that many Fibonacci numbers and print them. Then print their average and their standard deviation.

  4. Exercise P6.12 in the text (page 267).

  5. Write a program that asks the user to enter a positive number. Then the program prints back whether the number is prime or not. (Recall that a number is prime if it is not divisible by any number except 1 and itself). After the program prints back whether the number is prime or not the user is given a chance to enter another number. If the user enters "quit" the program ends. If the user enters a number the program checks to see if it is prime or not, prints the result, and the loops continues.

  6. Excercise P6.13 in the text (page 267).

  7. Writes a program stenographer that accepts lines of text from the user and translates them (one by one) in shorthand. For the purposes of this exercise let's define shorthand notation as the one in which all vowels are removed from all the words everywhere. Thus shorthand version of
    Good evening, and welcome to Minneapolis!
    would be
    Gd vnng, nd wlcm t Mnnpls!
  8. Write a program that creates a two-dimensional array that is specified by the user in the following way: first ask the user to enter a number. Your array will have rows and columns that are as long as this number (specified by the user) indicates. So the two dimensional array will essentially be a square, where the size is specified by the user. After entering the size, the user is asked to enter the rows of the array, one row per line, numbers on each line being separated by spaces. At the end the program prints the square of numbers back, for the user to see it.

  9. Now do problem P11.15 in the book (page 475).

  10. Now do problem P11.16 (page 476) in the book.

  11. Try problem P11.9 (page 474) and tell me what you think of it.

  12. Write a program that reads an array of numbers and then prints it back with all the duplicates removed. (This is like exercise R15.10 in the book, page 646, which also gives away the solution.) Use a loop to let the user do this over and over again, or take the numbers from the command line arguments that the main method is receiving.

  13. Do exercise R11.2 on page 470 in the book for uni- and two-dimensional arrays.

  14. Same for exercise R11.3 on page 470 in the book.

  15. Write a simple test program that illustrates how the average method defined on page 443 in the book can work on an array that has been generated by the method randomData defined on the next page. Incorporate user-input in your program, perhaps by asking (in a loop) the size of the array that has to be generated. Make sure the program produces an output that is meaningful to the user.

  16. Experiment with problem R7.4 in the book (page 306).

  17. Look at what section 6.5.4 (page 251 in the book) develops.

  18. Look at what section 6.5.3 (page 246 in the book) develops.

  19. Use the technique illustrated in section 6.4 (pages 237-239) to initialize a two-dimensional array with those numbers.

  20. Redo lab assignment six (6) by first creating the pattern in a two-dimensional array of characters then printing the array out.

  21. Define a class Player that will help you put forth your ideas about basketball.

    Each Player has a position on the floor (expressed as a pair of x and y coordinates) and may or may not be in possesion. (You could simulate that through an instance variable of type boolean or by defining a class Ball and having an instance variable of this type in each instance of type Player. If this variable is not null then the player is in possession).

    Then create five players, place them on the parquet, give one of them the ball and set up a play (of the kind you see on TV, for example here).

Well, I think this should get us started.

I will also post a set of chapters in the book to be reviewed, page by page.

Last updated: Mar 21, 2001 by Adrian German for A201