Additional Programming Projects

 

Since most of your time in this class should be spent coding, the programming projects described below are to

be completed during any "free" time that you might have after completing each of your regular assignments.

 

1)       Write a program that lets the user enter a list of real numbers, with no limit on how many numbers may be entered.  After each number is entered, the program should display three values:  a count of how many numbers have been entered so far, the sum of those numbers, and the mean (average) of all of the numbers entered up to that point.  All three of the values should be displayed at the same time.  Your program should include thorough error trapping for bad user input, such as letters, spaces, and other characters.

 

 

 

2)       Write a program that has the user enter a positive integer.  Then have the program display all of the factors of that number.  (A factor is an integer that divides into another integer with no remainder.  For example, 1, 2, 3, 6, 9, and 18 are all factors of 18.)  Your program should include thorough error trapping for bad user input, such as non-integers, zero, letters, spaces, and other characters.

 

 

 

3)       Write a program that displays all of the integers from 1 to 100 in random order.  Each number should be displayed exactly once.  Format the output so that all 100 numbers are displayed on one screen at the same time.

 

 

 

4)       Write a program that randomly generates 500 integers between 1 and 50 inclusive.  The random integers should not be displayed.  Instead, after generating the 500 integers, your program should display the frequency with which each integer was generated.  In other words, each of the integers from 1 to 50 should be displayed, along with the number of times that each of those integers was generated.  The display should be arranged neatly in a table so that it fits entirely on one screen.

 

 

 

5)       Write a "number guessing game" in which the computer randomly generates a number (a positive integer).  The user is then permitted to make guesses as to the identity of the number.  After each guess the computer should tell the user whether the guess was too high, too low, or just right (the correct number).  At the beginning of the program the user should be prompted to choose the upper and lower number boundaries (the range from which the randomly generated integer should be chosen).  The user should also decide how many guesses are allowed before the computer reveals the chosen number.  Finally, after each game the user should be given the opportunity to play the game again using the same user-chosen conditions, but with a new computer-generated random number.  All numbers entered by the user should be positive integers, and the computer should make sure the upper boundary is greater than the lower boundary.  Out-of-bounds and invalid guesses made by the user should not cause the remaining number of allowed guesses to decrease.  Your program should include thorough error trapping routines wherever data are entered by the user.

 

 

 

6)       To the above program, add a feature that tells the user the minimum number of guesses needed to determine the random number generated by the computer (assuming the user makes the guesses as efficiently as possible).  This information should be presented to the user after the upper and lower boundaries have been entered, but before the user chooses the number of guesses allowed.  For example, if the user asks to have a random integer generated from 1 to 100, the computer should determine that exactly 7 guesses are required (assuming that the user starts guessing with 50, then cuts that in half, then cuts that result approximately in half, and so on).

 

 

 

7)       Write a program that can solve the following problem and all problems like it:  "You are by a river and have two empty jugs.  One jug can hold exactly eight cups of water while the other jug can hold exactly five cups of water.  The jugs contain no markings.  With nothing else to aid you, how can you measure out exactly four cups of water?"  Your program should calculate an answer and then display a detailed, step-by-step solution to the user.  When your program first starts, the user should be prompted to enter the size of the first jug (in cups), the size of the second jug (also in cups), and the number of cups that are to be measured out.  The user should be allowed to enter the jug sizes in any order.  Your program should accept only positive integers, and it should include thorough error trapping in case the user enters improper data (non-integers, negative numbers, words, etc.).  The program should also tell the user if it is not possible to obtain the requested number of cups (based on the entered jug sizes).  For an example of a working, Visual Basic version of the program, see RiverJugs.exe.

 

 

 

8)       Write a program that systematically finds all of the solutions to the following problem:  "Using all of the digits one through nine, each exactly once, in progressive order, and with the help of only plus and minus signs, create equations that equal 100."  For example, (1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 = 100) is one solution.  There are many more.

 

 

 

9)       Write a "partial" anagram maker program.  An anagram is a word that can be formed using all of the letters from another word.  Your program should have the user enter a word.  Then the program should list every possible permutation of letters that can be formed from the user's initial word.  (For this project, don't worry about trying to figure out which permutations are actual words and which are gibberish.)  Your program should include thorough error trapping for bad user input, such as numbers, spaces, and other characters.

 

 

 

10)   To the above program, add a feature that checks each computer-generated permutation to see if it is actually a real word in the English language.  To do this, your program should use a master word list text file, which can be provided to you by the instructor.  This revised version of the program should display only the permutations of letters that form real words.