Tossing Coins for a Dollar
Create a game program using the Coin class from
When the game begins, your starting balance is $0. During each round of the game, the program will toss each of the simulated coins. When a tossed coin lands heads-up, the value of the coin is added to your balance. 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. If your balance exceeds one dollar, you lose.
Trending nowThis is a popular solution!
Chapter 7 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Modern Database Management (12th Edition)
Java How To Program (Early Objects)
Software Engineering (10th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting out with Visual C# (4th Edition)
Concepts of Programming Languages (11th Edition)
- The Spider Game Introduction: In this assignment you will be implementing a game that simulates a spider hunting for food using python. The game is played on a varying size grid board. The player controls a spider. The spider, being a fast creature, moves in the pattern that emulates a knight from the game of chess. There is also an ant that slowly moves across the board, taking steps of one square in one of the eight directions. The spider's goal is to eat the ant by entering the square it currently occupies, at which point another ant begins moving across the board from a random starting location. Game Definition: The above Figure illustrates the game. The yellow box shows the location of the spider. The green box is the current location of the ant. The blue boxes are the possible moves the spider could make. The red arrow shows the direction that the ant is moving - which, in this case, is the horizontal X-direction. When the ant is eaten, a new ant is randomly placed on one of the…arrow_forwardJava Programming Travel Tickets Company sells tickets for airlines, tours, and other travel-related services. Because ticket agents frequently mistype long ticket numbers, Travel Tickets has asked you to write an application that indicates invalid ticket number entries. The class prompts a ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you drop the last digit of the number, then divide the number by 7, the remainder of the division will be identical to the last dropped digit. This process is illustrated in the following example: Step 1. Enter the ticket number; for example, 123454. Step 2. Remove the last digit, leaving 12345. Step 3. Determine the remainder when the ticket number is divided by 7. In this case, 12345 divided by 7 leaves a remainder of 4. Step 4. Assign the Boolean value of the comparison between the remainder and the digit dropped from the ticket number. Step 5. Display the result—true or false—in a message box. Accept the…arrow_forwardAssignment2 Public Class name: wealth Write whole code inside main methodarrow_forward
- Questionarrow_forwardAssignment: Dice Rolling Program Objective: Create a Java program that rolls two dice and displays the results. The program should have two Java classes: one for a single die and another for a pair of dice. Assignment Details: User Input: Ask the user to specify the number of sides they want on each die. Ensure that the user's input is within a reasonable range. Dice Rolling: Simulate rolling the dice using Math.random() based on the user's chosen number of sides. Display the sum of the values rolled, e.g., "5 + 3 = 8." Special Combinations: If the dice roll results in combinations of 2, 7, or 12, print special messages: "1 + 1 = 2 snake eyes!" "3 + 4 = 7 craps!" "6 + 6 = 12 box cars!" Main Method: In the main method, create a pair of dice, roll them, and display the results. Allow the user to decide whether to continue rolling the dice or exit the program. Additional Features: You are welcome to add more features or enhancements to the program if desired. In…arrow_forwardExercise 6 - Loaded Coin Simulation Make a new class in the Lab2 project called LoadedCoinSim that simulates the toss of a loaded coin. A coin is loaded when it is constructed such that it is more likely to land on one value than another. Assume the probability the coin will land head is HEAD_PROB, and declare that as a constant in your program. Initially, use a value of 0.75, which means 75% chance the coin will show heads. Given this probability, simulate ten coin tosses and displaying the result. At the end, display the number of times the coin showed heads. The output should appear like this: Toss 1: HEADS Toss 2: HEADS Toss 3: HEADS Toss 4: TAILS Toss 5: HEADS Toss 6: HEADS Toss 7: HEADS Toss 8: HEADS Toss 9: TAILS Toss 10: HEADS Number of heads = 8arrow_forward
- Visual Basic For tax purposes an item may be depreciated over a period of several years, n.With the straight line method of depreciation, each year the item depreciates by 1/nth of itsoriginal value. With the double declining balance method of depreciation, each year the itemdepreciates by 2/nths of its value at the beginning of that year. (In the final year it is depreciatedby its value at the beginning of the year.)Write a program that performs the following tasks:1.1 Request a depreciation of the item, the year of purchase, the cost of the item, the number ofyears to be depreciated (estimated life), and the method of depreciation. The method ofdepreciation should be chosen by clicking on one of two buttons.1.2 Display a year by year description of the depreciation.arrow_forwardVisual Basic For tax purposes an item may be depreciated over a period of several years, n.With the straight line method of depreciation, each year the item depreciates by 1/nth of itsoriginal value. With the double declining balance method of depreciation, each year the itemdepreciates by 2/nths of its value at the beginning of that year. (In the final year it is depreciatedby its value at the beginning of the year.)Write a program using Visual Basic that performs the following tasks:1.1 Request a depreciation of the item, the year of purchase, the cost of the item, the number ofyears to be depreciated (estimated life), and the method of depreciation. The method ofdepreciation should be chosen by clicking on one of two buttons.1.2 Display a year by year description of the depreciation.arrow_forwardIn C# language using Microsoft Visual Studio in Windows Forms App (.NET Framework) A slot machine is a gambling device that the user inserts money into and then pulls a lever (or presses a button). The slot machine then displays a set of random images. If two or more of the images match, the user wins an amount of money, which the slot machine dispenses back to the user. Design a program that simulates a slot machine. When the program runs, it should do the following: Ask the user to enter the amount of money he or she wants to insert into the slot machine. Create an application that simulates a slot machine. The application should let the user enter into a TextBox the amount of money he or she is inserting into the machine. When the user clicks the Spin button, the application should display three randomly selected symbols. (Slot machines traditionally display fruit symbols.arrow_forward
- 9. Rock, Paper, Scissors Game Create a JavaFX application that lets the user play the game of rock, paper, scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is gener- ated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer's choice yet.) 2. The user selects his or her choice of rock, paper, or scissors by clicking a Button. An image of the user's choice should be displayed in an ImageView component. (You will find rock, paper, and scissors image files in the book's Student Sample Files.) 3. An image of the computer's choice is displayed. 4. A winner is selected according to the following rules: • If one player chooses rock and the other player chooses scissors, then rock wins. (Rock smashes scissors.) • If one player chooses scissors and the other…arrow_forwardGreetings. The programming language to be used is: JAVA Please write a GUI that implements a game, where the user has to click the buttons in the order of their numbering. * The 9 buttons are arranged in a grid of 3 by 3. Each one has a different number from 1 to 9. * If the user selects the correct button, it should turn green and become disabled. The score should beincremented by 1. * If the user selects the incorrect button, it should turn red and all the buttons should become disabled. * If the user selects the “Reset” button, all buttons should be white and become enabled, their random numbers should be reassigned and the score set to 0. Thank you.arrow_forwardC# Console Application for Minesweeper In this milestone, students will create three classes: Cell, Board, and Program. Create a class that models a game cell. A game cell should have the following properties: a.Its row and column. These should initially be set to -1. b.Its visited boolean value. This should initially be set to false. c.Live boolean value. This should initially be set to false. "Live" set to true will indicate that the cell is a "live bomb" cell. d.The number of neighbors that are "live." This should initially be set to 0. The Cell class should have a constructor, as well as getters and setters for all properties. 3.Create a class that models a game board. A game board should have the following properties: a.Size. The board will be square, where the size includes the dimensions of both the length and width of the board. b.Grid. The grid will be a 2-dimensional array of the type cell. c.Difficulty. A percentage of cells that will be set to "live" status. 4.The Board…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT