Question: Horizontal Ruler Problem Description: a recursive solution to printing an English Ruler with adjustable lengths and number of tick marks. It produced output vertically, like
Horizontal Ruler
Problem Description:
a recursive solution to printing an English Ruler with adjustable lengths
and number of tick marks. It produced output vertically, like this:
see image
Ruler of length with major tick length
For this program, you are to print out rulers horizontally, like this:
see image
Notes:
You must start with the code we went over in class: Ruler.java
Your solution must be recursive
Your output must include your name.
Your program should run the three test cases that are already in Ruler.java
Ruler.java:
public class Ruler
public static void drawRulerint nInches, int majorLength
drawLinemajorLength; draw inch line and label
for int j ; j nInches; j
drawIntervalmajorLength ; draw interior ticks for inch
drawLinemajorLength j; draw inch j line and label
private static void drawIntervalint centralLength
if centralLength otherwise, do nothing
drawIntervalcentralLength ; recursively draw top interval
drawLinecentralLength; draw center tick line without label
drawIntervalcentralLength ; recursively draw bottom interval
private static void drawLineint tickLength, int tickLabel
for int j ; j tickLength; j
System.out.print;
if tickLabel
System.out.print tickLabel;
System.out.print
;
private static void drawLineint tickLength
drawLinetickLength;
public static void mainString args
System.out.print
Ruler of length with major tick length
;
drawRuler;
System.out.print
Ruler of length with major tick length
;
drawRuler;
System.out.print
Ruler of length with major tick length
;
drawRuler;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
