Question: Write a recursive program Ruler to plot the subdivisions of a ruler using StdDraw, as in Program 1.2.1. Program 1.2.1 String concatenation public class Ruler

Write a recursive program Ruler to plot the subdivisions of a ruler using StdDraw, as in Program 1.2.1.Program 1.2.1 String concatenation public class Ruler { public static void main(String[]

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

Step by Step Solution

3.37 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets break down the problem and create a recursive program to plot ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithm Design Questions!