Site Navigation

Site Search

CS 110: Program 7 main content

Student Learning Objectives

Program 7 Assignment

Write a program that allows its user to play the dice game "Doubles"

Rules of the game

Class Design

The Die class will be similar to your Coin class done in Lab 11 except that the instance variable representing the die's face value should be an integer type (to store the value 1 to 6).

Tip: The Random class method nextInt(int n) returns a random integer value between 0 to n-1. To generate a random integer between 1 to 6 you can use

randomNumberGenerator.nextInt(6) + 1

Sample Session

You have $10.00
How much would you like to bet? 5.00
You rolled a one and one
You win $10.00

You have $20.00
How much would you like to bet? 5.00
You rolled a five and four
You lose $5.00

You have $15.00
How much would you like to bet? 15.00
You rolled a six and two
You lose $15.00

Better luck next time

What to turn in

File Header Comment

Include a file header comment at the top of every source code file. Include the assignment number, your cs110 account number, your name, completion time, and the honor code.

Remember, program assignments are to be done on your own. If you receive help understanding or debugging the assignment, you must acknowledge the person who helped. You must do the coding on your own.

//**********************************************************
// Assignment: Program 7
// Account: (Enter your cs110 account number here)
//
// Author: (Enter your full name here)
//
// Completion time: (Enter the total number of hours you
//                   spent on the assignment)
//
// Honor Code: I pledge that this program represents my own
//   program code. I received help from (enter the names of
//   others that helped with the assignment, write no one if
//   you received no help) in understanding and debugging my program.
//*********************************************************

Grading Criteria

20 points possible
CS 110 Program 7 Grading Sheet (PDF)