Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 11, Problem 10PP
Program Plan Intro
Fractal
Program plan:
- Import required packages
- Define the class “Fractal”.
- Declare the required static variables.
- Define the class “main”
- Call the method “launch()”.
- Define the method “start()”.
- Create an object for “Group()”, “Scene()”, “Canvas()” and “GraphicsContext()”.
- Call the method “drawFractal()”.
- Set the title for the frame.
- Set the scene for the frame.
- Call the method “show()”.
- Define the method “drawFractal()”.
- Check whether “k” equals to “0”.
- Call the method “strokeLine()”.
- Otherwise, check whether “p1x” equals to “p2x”.
- Calculate the length.
- Assign the calculated length to variable “third”.
- Call the method to draw line in vertical order.
- Otherwise, calculate the length.
- Assign the calculated length to variable “third”.
- Call the method to draw line in horizontal order.
- Check whether “k” equals to “0”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
please code in python
You place a pawn at the top left corner of an n-by-n chess board, labeled (0,0). For each move, you have a choice: move the pawn down a single space, or move the pawn down one space and right one space. That is, if the pawn is at position (i,j), you can move the pawn to (i+1,j) or (i+1, j+1).
Ask the user for the size of a chessboard, n (integer). Find the number of different paths starting from (0,0) that the pawn could take to reach each position on the chess board. For example, there are two different paths the pawn can take to reach (2,1). Look at the diagrams below to convince yourself of this. You can see the four paths that you can take by move 2.
Start -> Move 1 -> Move 2
(0,0) -> (1,0) -> (2,1)
(0,0) -> (1,0) -> (2,0)
(0,0) -> (1,1) -> (2,1)
(0,0) -> (1,1) -> (2,2)
Print the board with the number of ways to reach each square labeled as shown below.
For example:
Enter a board size: 4
1 0 0 0
1 1 0 0
1 2 1 0
1 3 3 1
Transcribed Image Text
Python Development Lab In Merworld there exists 2 coins of different denominations types 5-peso coins and 10- peso coins, both having two faces with image of – Elon Musk and a dog. You are assigned a task to find out the number of ways to arrange these coins so that their sum is N pesos. Arrangement should be done in such a way that the first coin in the arrangement should always have Elon Musk image up. Other coins could have any image. Input Output 1 60 5 LO
JAVASCRIPT SOLUTION PLEASE
You are going to be given a word. Your job is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters.
Chapter 11 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 11.1 - What output will be produced by the following...Ch. 11.1 - What is the output produced by the following code?Ch. 11.1 - Write a recursive definition for the following...Ch. 11.1 - What is the output of the following code? public...Ch. 11.1 - Prob. 5STQCh. 11.1 - Complete the definition of the following method....Ch. 11.2 - Revise the method getCount in Listing 11.5 so that...Ch. 11.2 - Prob. 8STQCh. 11.2 - Prob. 9STQCh. 11.2 - Suppose you want me class ArraySearcher to work...
Ch. 11.2 - What Java statement will sort the following array,...Ch. 11.2 - How would you change the class MergeSort so that...Ch. 11.2 - How would you change the class MergeSort so that...Ch. 11.2 - If a value in an array of base type int occurs...Ch. 11.3 - Convert the following event handler to use the...Ch. 11 - What output will be produced by the following...Ch. 11 - What output will be produced by the following...Ch. 11 - Write a recursive method that will compute the...Ch. 11 - Write a recursive method that will compute the sum...Ch. 11 - Complete a recursive definition of the following...Ch. 11 - Write a recursive method that will compute the sum...Ch. 11 - Write a recursive method that will find and return...Ch. 11 - Prob. 8ECh. 11 - Write a recursive method that will compute...Ch. 11 - Suppose we want to compute the amount of money in...Ch. 11 - Prob. 11ECh. 11 - Write a recursive method that will count the...Ch. 11 - Write a recursive method that will remove all the...Ch. 11 - Write a recursive method that will duplicate each...Ch. 11 - Write a recursive method that will reverse the...Ch. 11 - Write a static recursive method that returns the...Ch. 11 - Write a static recursive method that returns the...Ch. 11 - One of the most common examples of recursion is an...Ch. 11 - A common example of a recursive formula is one to...Ch. 11 - A palindrome is a string that reads the same...Ch. 11 - A geometric progression is defined as the product...Ch. 11 - The Fibonacci sequence occurs frequently in nature...Ch. 11 - Prob. 4PPCh. 11 - Once upon a time in a kingdom far away, the king...Ch. 11 - There are n people in a room, where n is an...Ch. 11 - Prob. 7PPCh. 11 - Prob. 10PPCh. 11 - Prob. 12PP
Knowledge Booster
Similar questions
- IN C PROGRAMMING LANGUAGE A resistor is a circuit device designed to have a specific resistance value between its ends. Resistance values are expressed in ohms (Ω) or kilo-ohms (kΩ). Resistors are frequently marked with colored bands that encode their resistance values, as shown in the Figure. The first two bands are digits, and the third is a power-of-ten multiplier. The Table below shows the meanings of each band color. For example, if the first band is green, the second is black, and the third is orange, the resistor has a value of 50 × 103 Ω or 50 k Ω. The information in the Table can be stored in a C program as an array of strings. char COLOR_CODES[10][7] = {"black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "gray", "white"}; Notice that “red” is COLOR_CODES[2] and has a digit value of 2 and a multiplier value of 102. In general, COLOR_CODES[n] has digit value n and multiplier value 10n. Write a program that prompts for the colors…arrow_forwardSee the sample outputs for more clarification. Project Specifications Input for this project: Values of the grid (row by row) Output for this project: Whether or not the grid is magic square Programmer's full name Project number Project due date Processing Requirements Use the following template to start your project: #include using namespace std; // Global constants // The number of rows in the array // The number of columns in the array // The value of the smallest number // The value of the largest number const int ROWS = 3; const int COLS = 3; const int MIN = 1; const int MAX = 9; // Function prototypes bool isMagicsquare(int arrayRow1[], int arrayRow2 [], int arrayRow3[], int size); bool checkRange (int arrayRow1[], int arrayRow2[], int arrayRow3[], int size, int min, int max); bool checkUnique(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size); bool checkRowSum (int arrayrow1[], int arrayrow2[], int arrayrow3[], int size); bool checkColiSum(int arrayrow1[], int…arrow_forwardIn programming language Java, make a programm that scans an array of numbers and then checks which numbers have ONLY one digit 7. For example: we input numbers 23, 143, 98, 2373, 77, 97, 7001. And it displays these numbers: 2373, 97, 7001. (Doesn't display 77 because it has 2 sevens).arrow_forward
- Easy Program Please answer fast: you will write a program that calculates the area for ANY regular polygon. Ask the user for the side length of the polygon (the type should be double) and the number of sides (the type should be int). The formula for calculating the area can be seen below and comes in three parts. First, calculate the perimeter of the polygon: given:- perimeter(reg_polygon)=slen*nsidesarrow_forwardWrite a program that creates a 2D array of size 4x5. Then, user enters the elements for this 2D array. Display the array in tabular form, using manipulators.arrow_forwardPython:Write a program that prompts you to type an integer value and indicates whether the number is: Positive torqueOdd positiveNegative torqueNegative oddFor this exercise, consider the value 0 as a positive pair.arrow_forward
- Write a program that prints an mxn matrix whose dimensions are specified by the user. Let the matrix values be random variables. You must use it within the repetition cycle. Example format: Enter dimension of matrix mxn: 2 4 The 2x4 matrix is : 1 2 3 4 5 6 7 8arrow_forwardWRITE A CODE IN C++ LANGUAGE To implement the multiplayer game with multiple players moving and collecting items concurrently, you can use the following steps: Step 1: Generate a random number between 10 - 99 and multiply it by the last digit of your roll number. Step 2: Divide your roll number with the generated number in step 1 and take the mod of the result with 25. Step 3: If the result in step 2 is less than 10, add 15 to it to get the board size. Step 4: Create an n x n board and initialize it with empty squares and randomly place items on some squares. Step 5: Create a thread for each player and pass the player's ID and starting position to the thread. Step 6: Each player thread should handle the player's movement and item collection. Step 7: When a player moves onto a square that contains an item, the player thread should send a message to the main thread indicating that the player has collected an item and the item's value. Step 8: The main thread should update the…arrow_forwardwrite java statement to shift the content of each cell of an integer array one place to the right, except for the content of the last cell, which should be moved into the cell with subscript 0. Thus for example, if the array looks like this: 0 1 2 3 4 5 2 9 3 7 then the array will be changed to look like this: 0 1 2 3 4 7 5 2 9 3arrow_forward
- So I am trying to create a card game but I want to generate random numbers from my array without having a repeat of the same numbers that have been deal for two hands. I am working in Javaarrow_forwardP1 P2 P3 P4 A pentagonal number is one that corresponds to dots arranged into a pentagon. Above are the first four pentagonal numbers and their pentagons. The pentagonal number PN has sides made of N dots. When you count the dots for a pentagonal number, include the dots for the inner pentagons. So to figure out how many dots PN has, find out how many P(N-1) has and add the dots for the new sides of size N. P1 = 1, P2 = 5, P3 = 12, P4 = 22 Figure out a recursive formula for PN and then write a function that implements it. That is, implement pentagonal() using recursion. pentagonal(1) -> 1 pentagonal(2) -> 5 pentagonal(3) -> 12arrow_forwardIn this c++ program you are asked to design a 2 x 2 x 2 Rubik's cube that is filled with numbers instead of colors. The cube, naturally, has six sides that are identified as follows: The front side is side 0 The right side is side 1 The backside side is side 2 The left side is side 3 The Up side is side 4 The bottom side is side 5 The squares on every side are initially filled with the same side index. This means that the four squares on the front side are filled with 0's, the four squares on the right side are filled with 1's, etc. You are allowed to move the cube in two directions only: Horizental move (H or h): The first row moves one step in four sides in this order (0 -> 1 -> 2 -> 3 -> 0) Vertical move (V or v): The left column moves one step in four sides in this order ( 0 -> 5 -> 2 -> 4 -> 0) The program accepts from the the user the number of moves he/she wants to make, accepts the sequence of desired moves as shown in the sample case below.…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education