SimpleSlot - Scanner sc = new Scanner(System.in); do {...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // SimpleSlot.java Author: Lewis and Loftus // // Solution to Programming Project 3.18 //******************************************************************** / import java.util.Scanner; i public class SimpleSlot { //----------------------------------------------------------------- // Plays a simple slot machine using digits. //----------------------------------------------------------------- public static void main (String[] args) { final int DIGITS = 10; int slot1, slot2, slot3; String again;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Scanner sc = new Scanner(System.in); do { slot1 = (int) (Math.random() * DIGITS); slot2 = (int) (Math.random() * DIGITS); slot3 = (int) (Math.random() * DIGITS); System.out.println (slot1 + " " + slot2 + " " + slot3); if (slot1 == slot2 && slot2 == slot3) System.out.println ("Jackpot!!!"); else if (slot1 == slot2 || slot2 == slot3 || slot1 == slot3) System.out.println ("Matched 2!!"); System.out.println(); System.out.print ("Play again (y/n)?: "); again = sc.nextLine(); } while (again.equalsIgnoreCase ("y")); } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online