For this assignment, you will create a game program using the Coin class from Pr
ID: 3812911 • Letter: F
Question
For this assignment, you will create a game program using the Coin class from Programming Challenge 12. The program should have three instances of the Coin class: one representing a quarter, one representing a dime, and one representing a nickel. When the game begins, your starting balance is $0. During each round of the game, the program will toss the simulated coins. When a coin is tossed, the value of the coin is added to your balance if it lands heads-up. For example, if the quarter lands headsup, 25 cents is added to your balance. Nothing is added to your balance for coins that land tails-up. The game is over when your balance reaches $1 or more. If your balance is exactly $1, you win the game. You lose if your balance exceeds $1.Explanation / Answer
Public class coin
{
public static void main()
{
double bal = 0;
string coin;
for (int i = 0;i<n;i++)
{
if(coin == head)
{
bal = bal + 1165;
}
system.out.println(bal);
if(bal == 64.41)
{
system.out.println("win");
}
else
{
system.out.println("loss");
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.