Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is Java. I am using NetBeans So I would appreciate it if the code was made with netbeans, Only because I am new to
This is Java. I am using NetBeans So I would appreciate it if the code was made with netbeans, Only because I am new to Java and I do not have much experience using other compilers. You need to make the coin toss simulator before making tossing coins for a dollar. I have tried so many times before.. but I keep failing. I would really appreciate the assistance thanks.
AT 12. Coin Toss Simulator Write a class named Coin. The coin class should have the following field: A String named sideUp. The sideUp field will hold either "heads" or "tails indicating the side of the coin that is facing up. The Coin class should have the following methods: A no-arg constructor that randomly determines the side of the coin that is facing up ("heads" or "tails") and initializes the sideUp field accordingly. A void method named toss that simulates the tossing of the coin. When the toss method is called, it randomly determines the side of the coin that is facing up ("heads or "tails) and sets the sideup field accordingly. A method named getSideUp that returns the value of the sideUp field. Write a program that demonstrates the coin class. The program should create an instance of the class and display the side that is initially facing up. Then, use a loop to toss the coin 20 times. Each time the coin is tossed, display the side that is facing up. The program should keep count of the number of times heads is facing up and the number of times tails is facing up, and display those values after the loop finishes. 13. Tossing Coins for a Dollar 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 heads-up, 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 one dollar or more. If your balance is exactly one dollar, you win the game. You lose if your balance exceeds one dollarStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started