ICS 111 Homework Assignment H01: Simulate a pair of dice.

Purpose

We are going to start our problem-solving education by writing a program that simulates a pair of dice.

This assignment will give you practice using Eclipse to create and test a Java program. Hopefully, you set up your Eclipse environment to make this assignment easier to complete.

Tasks

1. Create a Java project in Eclipse with your UH username

This project is where we will be doing all our homework assignments for ICS 111. Here’s a screen shot of my Eclipse with my cmoore project. eclipse

2. Create a package named edu.ics111.h01

This is where we will put all our classes for homework 01. To create a package right mouse click on the project, choose new, then choose package. new package

In the dialog box type in ‘edu.ics111.h01’. Packages are Java’s way of grouping things together. We are going to put all of our Java files for each homework in a different package.

Here’s a screen shot of my workspace with the package.

package.

3. Simulate rolling two six-sided die.

Write a program that simulates rolling a pair of dice. The program should output the value of each die and the sum of the two dice. Your output should look something like:

The first die comes up 3
The second die comes up 5
Your total roll is 8

To create a program in Eclipse right mouse click on the package, choose New -> Class then fill out the information in the dialog. Here’s a screen shot of my SixSidedDieSimulation dialog.

SixSidedDieSimulation

I decided to name my class ‘SixSidedDieSimulation’ since that is a descriptive name for what the program does. Also notice I chose ‘public staic void main(String[] args)’ and ‘Generate comments’. These choices will add a main method and comments. Here’s a screen shoot of the Java code generated.

SixSidedDieSimulation Class

Note: I’ve turned on Checkstyle, so I have 5 Warnings I need to fix if I want full credit for the homework.

Now we can start working on solving the problem of simulating two six-sided die. What are the steps we need to take? How do we get a random number? Hint

4. Simulate rolling two twenty-sided die.

Create another program to simulate two 20 sided dice. Follow the same steps as above to create the Java program and solve the problem.

Bonus Problem: Ask the user for the number of sides.

Create a third program that asks the user for the number of sides for the dice, then simulate rolling them. What do you do if they give a bad answer?

Grading Rubric

CriterionExcellent (100%)Satisfactory (75%)Borderline (50%)Unsatisfactory (25%)Poor (0)
Adherence to standards - 2 points
Does it conform to standards in every detail?
No errors. Minor details of the assignment are violated, or poor choices are made where the assignment is unclear. Significant details of the assignment or the underlying program intent are violated, but the program still fulfills essential functions. Significant details of the assignment or the underlying program intent are violated, but the program still fulfills some essential functions. Misses the point of the assignment.
Breakdown (modular design) - 1 point
Does it demonstrate good modular design?
No errors. 1-3 minor errors. > 3 minor errors OR 1 major error. 2 major errors > 2 major error.
Correctness of code - 5 points
Does it work? Does it pass JUnit?
Passes all tests. Works for typical input, may fail for minor special cases. Fails for typical input, for a minor reason. Fails for typical input, for a major reason. No.
Documentation, and style - 2 points
Is it clear and maintainable? Does it pass CheckStyle?
No errors. 1-3 minor errors. > 3 minor errors OR 1 major error. 2 major errors > 2 major error.

Turning in the Assignment

The assignment is due on Friday, September 3rd at 11:55pm. You may turn it in early.