import java.util.*;

public class SlotMachine
{
	// Program to simulate five spins of a slot machine.

	// Name:
	// Section:
	// Andrew ID:

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);

		int winnings = 0;
		String wheel1, wheel2, wheel3;
		int bet;

		System.out.println("WELCOME TO THE SLOT MACHINE!");
		System.out.println("Your total winnings = $" + winnings);

		for (int i = 1; i <= 5; i++) {
			do {
				System.out.print("How many dollars do you want to bet (1-4)? ");
				bet = scan.nextInt();
			} while (bet < 1 || bet > 4);

			wheel1 = getFruit((int)(Math.random()*4));
			wheel2 = getFruit((int)(Math.random()*4));
			wheel3 = getFruit((int)(Math.random()*4));

			System.out.println("You spun: " + wheel1 + " " + wheel2 + " " + wheel3);

			if (wheel1.equals(wheel2) && wheel2.equals(wheel3)) {
				System.out.println("You win $" + (bet*50) + "!");
				winnings += bet * 50;
			}
			else if (wheel1.equals(wheel2) || wheel2.equals(wheel3) || wheel1.equals(wheel3)) {
				System.out.println("You win $" + (bet*5) + "!");
				winnings += bet * 5;
			}
			else {
				System.out.println("Sorry, you do not win any money.");	
			}
			System.out.println("Your total winnings = $" + winnings);
		}

		System.out.println("THANK YOU FOR PLAYING THE SLOT MACHINE!");

	}

	public static String getFruit(int value) {
		if (value == 0) return new String("BANANA");
		if (value == 1) return new String("ORANGE");
		if (value == 2) return new String("RAISIN");
		if (value == 3) return new String("CHERRY");
		return new String("??????");
	}

}
