CSC 210 Introduction to Programming with Java
The purpose of this project is to allow you to practice the use of selection and loops
within your programs.
Submission
The resulting programs will be submitted to iLearn before the due date, specified
above, as a zip file containing only .java files, and an external documentation file
(preferably a pdf). This zip file should be named using the following convention:
p1.firstName.lastName.submissionDate.zip. For example, my submission file would be
named p1.john.roberts.2.26.zip.
Requirements
Complete the following exercises:
Problem 1 - Histogram
Write a program that prompts the user for a number N. This number will be used to
prompt the user N times to provide an integer. The program will then print the
frequency of the numbers entered as a histogram, displaying each of the numbers
entered from the minimum to the maximum. Frequency should be represented by the
‘*’ character for each appearance of the number.
Sample Run:
How many integers should I collect? 5
1: 9
2: 7
3: 7
4: 8
5: 4
4: *
5:
6:
7: **
8: *
9: *Problem 2 - Stats
Write a program that prompts the user for a number, N. This number will be used to
prompt the user N times to provide an integer. The program will then print the integers
out in the order they were entered, followed by the integers in reverse order.
Sample Run:
How many integers should I collect? 10
1: 9
2: -5
3: 107
4: 42
5: 3
6: 6
7: 8577
8: 0
9: 2
10: 1
9 -5 107 42 3 6 8577 0 2 1
1 2 0 8577 6 3 42 107 -5 9
Problem 3 - Tic Tac Toe
Write a program that will allow two users to play tic-tac-toe. The program should ask for
moves alternately from player One(X) and player Two(O). The program displays the
game positions as follows:
1 2 3
4 5 6
7 8 9
The players enter their moves by entering the position number they wish to mark. After
each move, the program displays the changed board. A sample board configuration is
as follows:
X X O
4 5 6
O 8 9
Player One’s (X) Turn:
The program ends when all available spaces have been played. (See extra credit,
below.) Players should not be allowed to over write an existing move.
Sample Run (Extra Credit Case):
1 2 3
4 5 6
7 8 9
Player One's (X) Turn: 1
X 2 34 5 6
7 8 9
Player Two's (O) Turn: 1
You entered an invalid move!
Player Two's (O) Turn: 2
X O 3
4 5 6
7 8 9
Player One's (X) Turn: 5
X O 3
4 X 6
7 8 9
Player Two's (O) Turn: 0
You entered an invalid move!
Player Two's (O) Turn: 3
X O O
4 X 6
7 8 9
Player One's (X) Turn: 9
Congratulations, Player One!
Extra Credit: If program keeps track of each entry and shows a message when one
player wins, then you will receive 50% extra credit for problem 2. A win should cause
the program to exit (instead of allowing all spaces to be consumed, as specified above.)
This is rather easy when you approach the problem in discrete steps, breaking down
each step into a logical collection of instructions to solve only that step...
Project Submission Guidelines
In each class you generate, you are expected to include:
1. The source code (of course)
2. Adequate comments
Your external documentation file is expected to include:
1. A description of the source code, including any assumptions you made during the
writing of the code. As an example, if you have written code that anticipates that user
input will be within a certain range, you should clearly document that assumption, and
the logic behind it. In addition, if you have written code that can handle input errors
(i.e. can handle user input outside of the range required, whether by responding with
an error message, or otherwise gracefully failing), you should document that as well.
2. A brief explanation of the flow of logic used to solve the problem. (Keep in mind that
this should have been developed before you actually write the code!)
3. A screen capture of the execution of each program. Screen captures can be done
differently on different platforms.Grading Policy
You will be graded based on correctness and documentation. Correctness implies both
that each of your programs compiles, and that each of your programs executes
according to the specification. Documentation should include all of the content specified
in requirements, above.
Refer to the syllabus for additional grading information, including late submission policy,
and compilation requirements.
As a reminder, any student found cheating on their project will receive a zero, and be
reported to the department for possible disciplinary action.