Tree Age
Counting the growth rings of a tree is a good way to tell the age of a tree. Each growth ring counts as one year. Use either the Circle or Ellipse classes to draw how the growth rings of a 5-year-old tree might look. Then, using the Text shape class, number each growth ring starting from the center and working outward with the age in years associated with that ring.
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Database Concepts (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Electric Circuits. (11th Edition)
- Create a class that represents the grade distribution for a given course. In this class you should write methods to perform the following tasks: Read the number of each of the letter grades A, B, C D and F Set the number of letter grades A, B, C, D and F Return the total number of grades Return the percentage of each letter grade as a whole number between 0 and 100 inclusive Draw a bar graph of the grade distributionThe graph should have five bars, one per grade. Each bar can be a horizontal row of asterisks, such that the number of asterisks in a row is proportionate to the percentage of grades in each category. For example, let on asterisk represent 2%, so 50 asterisks correspond to 100%. Mark the horizontal axis at 10% increments from 0 to 100% and label each line with a letter grade.For example, if the grades are entered as 1A, 4B's, 6C's, 2D's and 1 F, then the output would look like: 0 10 20 30 40 50 60 70 80 90 100 IIIIIIIIIII **************************************************…arrow_forward#The game Mancala is one of the oldest games in recorded #history. You can read more about it here: #https://www.thesprucecrafts.com/how-to-play-mancala-409424 # #For this problem, though, you don't need to know how to #play the game. All you need to know is the board layout #and the conditions for winning. # #A Mancala board is made of two rows of 6 cups, with two #bigger cups at the ends. Each cup holds some number of #stones or chips. For our purposes, though, we'll include #the bigger cups at the end of the corresponding rows. # #So, for us, a Mancala board is represented as a #2-dimensional list of integers. Each item in the lists #represents a cup, and the number represents how many #stones are currently in that cup. For example, this #could be one board: # # [[5, 3, 0, 2, 6, 8, 1], # [1, 6, 8, 0, 4, 1, 4]] # #With this board representation, the game is over when #every cup is empty except the top left and the bottom #right. When the game is over, whoever has more stones #in…arrow_forwardBriefly explain the concept of Encapsulation. Also explain how Encapsulation can be achieved.arrow_forward
- Bisection method only octave/math labarrow_forwardTranscribed Image Text JAVA Programming Problem: In the game of "Assassin's Creed", you control a ship with a cannon which is attacking a large enemy Assassin's Creed, armed with many guns. Your goal is to destroy as many of the guns as possible. The battle field is a 2D Cartesian grid, where your cannon is located at the origin. The enemy Assassin's Creed is a horizontal line segment located from the coordinates (X1, Y) to (X2, Y). There are exactly (X2 - X1 + 1) guns on the ship, located at the integer points (X1, Y), (X1+1, Y), ..., (X2, Y). However, the problem is, you cannot always fire at a gun. There are supernatural rocks located at all points of the battlefield whose X and Y coordinates are both integers. In order to fire successfully at an enemy's gun, the line connecting your cannon and that gun must not go through any rocks. Develop a JAVA code to output the number of the enemy battleship's guns that your cannon can destroy. Test Case Result 1 2 2 -2arrow_forwardmaximum hours (inclusive). Make sure to cast the maximum range to an int before using it as parameter invoke the method to start the engine invoke the fly method and use as the input parameter the random number generated on the previous step invoke the method to land the plane and stop the engine invoke the addGas method. Invoke the calcGasNeededToFillTank () method to figure out the fuel needed to fill the tank and pass this value as input parameter to the addGas method.arrow_forward
- Word Sleuth Puzzle Programarrow_forwardPython Turtle Graphics Draw a spiral diagram using Python turtle package program follows 3 steps: Import the turtle module Create a turtle to control. Draw around using the turtle methods. You should consider the following points in your solution: The shapes should be drawn with the shown colors Yellow and white for the square-like shapes. Blue for the background. The prompt should have a turtle shape. The number of iterations should be 300 You should use only one loop. The number of the yellow color lines should be 200. The final shape of the output should be as shown in the picture attached. Make sure to set properly the starting position (x & y) of your drawing, to maintain the required diagram. video on youtube: https://www.youtube.com/watch?v=ZqoJD2RMu1Iarrow_forwardMonty Hall Problem – Coding Lab In this lab, you will write a code that simulates the Monty Hall Game Show. Thegame host gives the participant the choice of selecting one of three doors. Twodoors has a goat behind them and one door has a prize. The set of choices arerandomized each round. The participant needs to select the door with the prizebehind it. When the participant selects a door, the game host reveals a door with agoat behind it. The game host opens a door (different from the one selected by theparticipant) that has a goat behind it. The participant is then given the option tochange their choice. When you run your code, the code would display a message prompting the user toinput their door choice, labelled as 1, 2, and 3. Then the code will display a doornumber (different from the one the user picked) with a goat behind it and ask theuser if they would like to change their choice. The code then displays a message onwhether the user guessed the correct door. The game then…arrow_forward
- Game Description: Pig is a game that has two players (in our case one human and one computer) that alternate turns. Each player’s goal is to get 100 points rolled on a normal six-sided die first. Each turn consists of the rolling the die repeatedly until you get a 1 or decide to stop. As long as you roll a 2-6, you will add this amount to your total for that turn. But if you roll a 1 during your turn, your turn ends and you receive zero points for that entire turn (erasing all of the progress you made since you last agreed to stop). If you decide to stop rolling at any point in your turn, your points for that turn are then added to the overall score. The overall score is then safe from future rolls. The trick is knowing how long to push it before we should stop and save our gains. See end of this document for an example of a game of pig we should write coding as below In order to explore what is the best strategy for the computer player (i.e. at what score do we stop each computer…arrow_forward8. Lo Shu Magic Square The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown in Figure 7-19 Q. The Lo Shu Magic Square has the following properties: Figure 7-19 Lo Shu Magic Square 9 2 4 3 5 7 8 1 • The grid contains the numbers 1 through 9 exactly. • The sum of each row, each column, and each diagonal all add up to the same number. This is shown in Figure 7-20 D. Figure 7-20 Sums of the rows, columns, and diagonals 15 4 +15 7 +15 8 1 6 +15 15 15 15 15 In a program, you can simulate a magic square using a two-dimensional array. Write a function that accepts a two-dimensional array as an argument, and determines whether the array is a Lo Shu Magic Square. Test the function in a program.arrow_forwardcanMove(int x, int y, int destX, int destY, Side s): This method returns true if the player of color s can move the piece at coordinates (x,y) can move to coordinates (destX, destY) on the board in its current state. This means that here you do need to consider this piece’s interaction with other pieces on the board. Conditions for this method to return false are given in the code. public boolean canMove(int x, int y, int destX, int destY, Side s){ /* TODO write a method that checks if a piece at coordinates x,y can move to coordinates destX,destY Conditions for false: - Origin or destination coordinates are outside the board - Piece at origin is null - If source and destination coordinates are the same - Piece at origin is not of the same side as s - You can check this using piece.getSide() - Piece cannot move to the destination by piece movement rules - You should check this using Piece.canMove(destX,…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education