Assignment H03: Simulate a pair of six sided dice

Purpose

We are going to continue our problem-solving education by writing a program that uses looping and branching to determine how many times it takes to roll two dice to get a seven. We are going to have to loop since it probably will take more than once to get a seven with two dice. We’ll have to decide (branch) if the sum of the two dice is seven.

We will also get more practice using Eclipse to make our programming life easier.

Tasks

1. Create a package named edu.ics111.h03 in your ICS111-workspace project

This is where we will put all our classes for homework 03.

2. Use the ICS 111 Programming Algorithm to write a program that answers the question “How many times does it take to roll a 7 with a pair of dice?”

How many times do you have to roll a pair of six sided dice before they come up seven? You could do the experiment by rolling the dice by hand. Write a computer program that simulates the experiment. The program should report the number of rolls that it makes before the dice come up seven.

The text’s Exercise 2.2 explained how to simulate rolling a pair of dice.

Read and understand the problem.

Do you understand what the program needs to do?

Create the Java file for your program and insert the Java boilerplate

Use the steps from H02 to create your Java program and boilerplate code.

Write the steps to solve the problem as comments in main and refine them

“What are the steps needed to solve this problem?” Write them down as comments in the main method. Once you have the steps start refining them till you can write Java code.

Some questions you should answer:

3. Use the Programming Algorithm to write a program that asks the user for what the target value for the dice is.

Write a program to ask the user for a number between 2 and 12, then run the simulation counting the rolls before the dice come up with the user’s choice. Output the number of rolls it took.

Read and understand the problem.

Do you understand what the program needs to do?

Create the Java file for your program and insert the Java boilerplate

Use the steps from H02 to create your Java program and boilerplate code.

Write the steps to solve the problem as comments in main and refine them

“What are the steps needed to solve this problem?” Write them down as comments in the main method. Once you have the steps start refining them till you can write Java code.

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 17th at 11:55pm. You may turn it in early.