Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help!! im struggling with this project!! Only java no IO. I cant seem to

ID: 3767568 • Letter: P

Question

Please help!! im struggling with this project!! Only java no IO. I cant seem to get my code to run without error!

For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totalling 8 or higher), Low (totalling 6 or less) or Sevens (totalling exactly 7). If the player wins, he receives a payout based on the schedule given in the table below:


The player will start with $100 for wagering. If the player chooses to wager $0 or if he runs out of money, the program should end. Otherwise it should ask him whether he's wagering on High, Low or Sevens, display the results of the die rolls, and update his money total accordingly.

For this assignment you must start with the following "skeleton" of Java code. Import this into your Eclipse workspace and fill in the methods as directed:

Project07.java**

Project 07 Sample Output

This is a sample transcript of what your program should do. Items in bold are user input and should not be put on the screen by your program.

You have 100 dollars.
Enter an amount to bet (0 to quit): 50
High, low or sevens (H/L/S): H
Die 1 rolls: 1
Die 2 rolls: 5
Total of two dice is: 6
You lost!

You have 50 dollars.
Enter an amount to bet (0 to quit): 25
High, low or sevens (H/L/S): L
Die 1 rolls: 6
Die 2 rolls: 2
Total of two dice is: 8
You lost!

You have 25 dollars.
Enter an amount to bet (0 to quit): 12
High, low or sevens (H/L/S): H
Die 1 rolls: 2
Die 2 rolls: 6
Total of two dice is: 8
You won 12 dollars!

You have 37 dollars.
Enter an amount to bet (0 to quit): 18
High, low or sevens (H/L/S): S
Die 1 rolls: 5
Die 2 rolls: 4
Total of two dice is: 9
You lost!

You have 19 dollars.
Enter an amount to bet (0 to quit): 9
High, low or sevens (H/L/S): H
Die 1 rolls: 3
Die 2 rolls: 3
Total of two dice is: 6
You lost!

You have 10 dollars.
Enter an amount to bet (0 to quit): 5
High, low or sevens (H/L/S): L
Die 1 rolls: 2
Die 2 rolls: 4
Total of two dice is: 6
You won 5 dollars!

You have 15 dollars.
Enter an amount to bet (0 to quit): 7
High, low or sevens (H/L/S): H
Die 1 rolls: 5
Die 2 rolls: 6
Total of two dice is: 11
You won 7 dollars!

You have 22 dollars.
Enter an amount to bet (0 to quit): 0

You have 22 dollars left
Goodbye!


Note that your output depends on the choices made by the user. Remember to check that the user's inputs are valid:

You have 100 dollars.
Enter an amount to bet (0 to quit): -100
Your bet MUST be between 0 and 100 dollars
You have 100 dollars.
Enter an amount to bet (0 to quit): 1000
Your bet MUST be between 0 and 100 dollars
You have 100 dollars.
Enter an amount to bet (0 to quit): 100
High, low or sevens (H/L/S): h
Die 1 rolls: 2
Die 2 rolls: 6
Total of two dice is: 8
You won 100 dollars!

You have 200 dollars.
Enter an amount to bet (0 to quit): 200
High, low or sevens (H/L/S): s
Die 1 rolls: 5
Die 2 rolls: 3
Total of two dice is: 8
You lost!

You have 0 dollars left
Goodbye!

**

Choice Payout High 1 x Wager Low 1 x Wager Sevens 4 x Wager

Explanation / Answer

package osu.cse.1223;

import java.util.Scanner;

public class Project07

{

public static void main(String[] args)

{
      
System.out.println("Hello! Welcome to Dice Hi-Lo");
System.out.println("You have $100 !");
int credit = 100;

while (credit > 0)

{

int bet = getBet();
int winnings = winAmount();
credit = credit - bet;

if (bet != 0)
  
{

   credit = credit + winnings;
   System.out.println("You now have $" + credit);

}
  
else

{

System.out.println("Thank you for playing.. Your balance is $"+ credit);
   break;

}

   System.out.println("Thank you for playing");
   System.out.println("Better luck next time");
      
}

}

private static int getBet(Scanner inScanner, int currentPool)

{

System.out.println("How much $ do you want to bet ?");
System.out.println("Input 0 to end");

Scanner inScanner = new Scanner(System.in);
int a = inScanner.nextInt();
      
return a;

}

private static char getHighLow(Scanner inScanner)

{

System.out.println("What do you want to bet ?");
System.out.println("Type H for Hi, L for Lo and S for Seven :");

Scanner inScanner = new Scanner(System.in);
char ch = inScanner.next().trim().charAt(0);
char chr = Character.toUpperCase(ch);
      
return chr;

}

private static int getRoll()

{

int a = (int) (Math.random() * 6) + 1;
return a;

}

private static int determineWinnigs(char highLow, int bet, int roll)

{

int rollOne = getRoll();
int rollTwo = getRoll();
int betAmount = getBet();
char chr = getHighLow();
int winAmount = 0;
char HighLow;

int roll = rollOne + rollTwo;

if (roll > 7)
{

System.out.println("It is a Hi");
HighLow = 'H';

} else if (roll < 7)

{

   System.out.println("It is a Lo");
   HighLow = 'L';

}
else
{

   System.out.println("It is a SEVEN");
   HighLow = 'S';

   }

   if (chr == HighLow)
{

   switch (chr)
{

   case 'H':

       winAmount = betAmount * 2;
       System.out.println("You win : " + winAmount);
       break;

   case 'L':

       winAmount = betAmount * 2;
       System.out.println("You win : " + winAmount);
       break;

   case 'S':

       winAmount = betAmount * 4;
       System.out.println("You win : " + winAmount);
       break;

   default:

       System.out.println("No amount");

   }

}
else
{

   winAmount = 0;
   System.out.println("You Lost !");

   }

   return winAmount;

}

}