Written by Tyler Conklin Based on past problems as created by Mehran Sahami, Keith Schwarz, Eric Roberts, Marty Stepp, and others.
Handouts:
Console Reference
Random Generator Reference
These are bonus programs! They are meant to be challenging. They are not listed in order of difficulty, so choose whichever programs sound interesting!
BonusConsole: Piglet.java
Write a console program for a 1-player dice game called "Piglet", based on the game "Pig". The player's goal is to get as many points as possible without rolling a 1. Each turn, the player rolls the die; if they roll a 1, the game ends and the player gets a score of 0. If the player rolls any number besides a 1, that number is added to their score. The player then chooses whether to roll again or end the game with his or her current score. Two sample game outputs are shown below.
BonusConsole: Conversion.java
America uses a confusing measurement system where units of length are measured in inches, feet, yards, and miles. There are twelve inches in a foot, and three feet in a yard. However when doing scientific measurements it is important to use centimeters, meters, and kilometers since these units of measurement are used worldwide and actually make sense. Write a program that converts from centimeters to inches given that there are 2.54 centimeters = 1 inch. Below is some sample output from the program.
BonusConsole: Fizzbuzz.java
Fizzbuzz is a classic coding problem. Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers that are multiples of both three and five print “FizzBuzz”. Below is some sample output for the first 16 numbers.