Write a recursive program Ruler to plot the subdivisions of a ruler using StdDraw, as in Program
Question:
Write a recursive program Ruler to plot the subdivisions of a ruler using StdDraw, as in Program 1.2.1.
Transcribed Image Text:
Program 1.2.1 String concatenation public class Ruler { public static void main(String[] args) { String ruler1 = "1"; String ruler2 = ruler1 + String ruler3 = ruler2 + " 2 + ruler1; " 3 + ruler2; + ruler3; String ruler4 = ruler3 + 4 System.out.println(ruler1); System.out.println(ruler2); System.out.println(ruler3); System.out.println(ruler4); } } This program prints the relative lengths of the subdivisions on a ruler. The nth line of output is the relative lengths of the marks on a ruler subdivided in intervals of 1/2" of an inch. For example, the fourth line of output gives the relative lengths of the marks that indicate intervals of one-sixteenth of an inch on a ruler. % javac Ruler.java % java Ruler 1 121 12 13 12 1 1 2 1 3 1 2 1 4 1 2 1 3 12 1 1 2 1 3 1 2 1 4 1 2 1 3 1 21 The ruler function for n = 4
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 0% (1 review)
Lets break down the problem and create a recursive program to plot ...View the full answer
Answered By
Muhammad Umair
I have done job as Embedded System Engineer for just four months but after it i have decided to open my own lab and to work on projects that i can launch my own product in market. I work on different softwares like Proteus, Mikroc to program Embedded Systems. My basic work is on Embedded Systems. I have skills in Autocad, Proteus, C++, C programming and i love to share these skills to other to enhance my knowledge too.
3.50+
1+ Reviews
10+ Question Solved
Related Book For
Introduction To Programming In Java An Interdisciplinary Approach
ISBN: 9780672337840
2nd Edition
Authors: Robert Sedgewick, Kevin Wayne
Question Posted:
Students also viewed these Algorithm Design questions
-
Write an illustrated essay on;a) Industrial Ecology and Clean Production.b) Environmental Risk Assessment.Q2. With reference to EIA/EA guidelines and any other information, discuss the...
-
Solve each equation. Check the solutions. 1 + n 2 n+1 = 2
-
In Problems 6 and 7, solve each triangle. 5 B a A 2
-
X H H H HCZO HONH HO HN. HOC H A variety of electrophiles (EY) will react with benzene, and derivatives of benzene, to yield substitution products. Halogenation of OH benzene rings is an reaction...
-
Munro Limited reports the following information in its tax files covering the five-year period from 2015 to 2019. All assets are Class 10 with a 30% maximum CCA, and no capital assets had been...
-
When a bond issue has been placed directly with an affiliate, what account balances will be stated incorrectly in the consolidated statements if the intercompany bond ownership is not eliminated in...
-
Celestial Inc. is organized into 3 distinct divisions. The company is currently contemplating the elimination of either Division 1 or Division 2 because they are showing a pre-tax loss. An annual...
-
a. What were HCA's liabilities-to-assets ratios and times-interest-earned ratios in the years 2005 through 2009? b. What percentage decline in EBIT could HCA have suffered each year between 2005 and...
-
Use the information in the table to answer (a) - (c) below. Stock A B C D Standard deviation 4% 9% 11%13% Beta .8 1.11.4 1.3 (a)Which stock will have the highest risk premium for an investor with a...
-
Write a program that takes a command-line argument n and creates an n-by-n boolean matrix with the element in row i and column j set to true if i and j are relatively prime, then shows the matrix on...
-
Write a static method max3() that takes three int arguments and returns the value of the largest one. Add an overloaded function that does the same thing with three double values.
-
Gary and Ann have a joint checking account. Their balance at the beginning of October was $9,145.87. During the month they made deposits totalling $2,783.71, wrote checks totalling $4,871.90, paid a...
-
The following balances were extracted from the subsidiary journals of General Spaza Shop as at 28 February 20.2. Cash receipts journal VAT input Sales column Cash payments journal Purchases column...
-
Let's talk pricing. Natural disasters such as severe hurricanes, the California wildfires, and extreme cold, bring up the idea of scarcity as many commodities such as water, building materials, and...
-
Management of Organizational Behavior Final Analytical Paper For the final analytical paper I want to give you an opportunity to reflect on an organizational behavior related issue that is...
-
Quary Company is considering an investment in machinery with the following information. Initial investment Useful life Materials, labor, and overhead (except depreciation) Depreciation-Machinery $...
-
Kai has heard of your fame as an economist who specializes in consumer behavior and optimizing people's well-being based on their choices. He comes to you for advice. Every day he consumes 3...
-
(a) Use the result for Problem 75 to find the ratio of the transmitted intensity to the incident intensity through N parallel slabs of glass for light of normal incidence. (b) Find this ratio for...
-
Using the information in P11-2B, compute the overhead controllable variance and the overhead volume variance. Data From Problem 11-2B: Huang Company uses a standard cost accounting system to account...
-
For this problem, carry at least four digits after the decimal in your calculations. Answers may vary slightly due to rounding. How hard is it to reach a businessperson by phone? Let p be the...
-
The current price of Pineapple stock is $50. In each of the next two years, this stock price can either go up by $12 or go down by $7. The stock pays no dividends. The oneyear risk-free interest rate...
-
The test statistic for this hypothesis test The P-value for this hypothesis test. Identify the conclusion for this hypothesis test.
Study smarter with the SolutionInn App