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% (2 reviews)
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...
-
Grady operates a lawn maintenance business using the accrual method. He estimates that 5 percent, or about $2,500 of his 2022 yearend customers invoices will never be paid. During 2022, he wrote off...
-
AIDS clinical trials. Now that effective treatments for AIDS are at last available, is it ethical to test treatments that may be less effective? Combinations of several powerful drugs reduce the...
-
The income statement of Jones Company for the year ended December 31, 2010, follows. Required a. Compute the net earnings remaining after removing nonrecurring items. b. Determine the earnings (loss)...
-
Prepare a vertical analysis of the income statement for Moran Corp. INSTRUCTONS: Prepare a vertical analysis of the income statement for Moran Corp. Moran Corp. Comparative Condensed Income Satement
-
Pat and Mandy are married and have a son, Steve, age 8. Mandy, age 29, earns $40,000 annually from her job. Pat, age 31, earns $50,000 annually from his job. Assume that Pat will die before Mandy....
-
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.
-
Given the following T-accounts, describe the transaction that took place on each specified date duringJuly: Cash Accounts Receivable Inventory Equipment 7/5 9,500 7/1 3,420 7/14 18,000 7/5 9,500 710...
-
For each of the following independent situations, state whether the following accounting practices are in accordance with or in violation of generally accepted accounting principles. Identify the...
-
Feather Friends, Incorporated, distributes a high-quality wooden birdhouse that sells for $120 per unit. Variable expenses are $60.00 per unit, and fixed expenses total $200,000 per year. Its...
-
How much is the over/underapplied FOH? (PLASTIC PRODUCTS) A company manufactures plastic products for the home and restaurant market. The company also does contract work for other customers and...
-
In the circuit below, identify how the resistors are connected and then identify the quantity that must always be the same for these resistors.
-
Consider two firms that operate in a perfectly competitive market. While producing their products, these firms generate pollution. Assume that it is possible to reduce pollution by adopting an...
-
Consider two products with the same margin carried by a retail store. Any leftover units of one product are worthless. Leftover units of the other product can be sold to outlet stores. Which product...
-
What are conversion costs? What are prime costs?
-
If John invested $20,000 in a stock paying annual qualifying dividends equal to 4% of his investment, what would the value of his investment be 5 years from now? Assume Johns marginal ordinary tax...
-
help asap please!
-
Please, help asap! I have one day. Feedback will be given. & show some work. [in Excel] For the final project you will need you to create a spreadsheet /proforma of the cash flows from a property....
Study smarter with the SolutionInn App