These are bonus programs! They are meant to be challenging. They are not listed in order of difficulty, so choose whichever programs sound interesting!

Piglet

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.

Welcome to Piglet!
You rolled a 5!
Roll again? yes
You rolled a 4!
Roll again? yes
You rolled a 1!
You got 0 points.

Welcome to Piglet!
You rolled a 6!
Roll again? yes
You rolled a 2!
Roll again? yes
You rolled a 2!
Roll again? no
You got 10 points.


Conversion

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.

This program can convert centimeters to inches
Enter cm: 2.54
2.54 centimeters equals 1.0 inches
Enter cm: 68
68.0 centimeters equals 26.771653543307085 inches
Enter cm: 100
100.0 centimeters equals 39.37007874015748 inches

You can now write a program to convert any kind of units that you want!


Fizzbuzz

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.

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16