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[]](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1711/9/6/7/075660a8b63b61571711967073239.jpg)
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
Lets break down the problem and create a recursive program to plot ... View full answer
Get step-by-step solutions from verified subject matter experts
