Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This question is for a program in Java. In the traditional English system of measurement, each inch on a ruler is marked off into fractions

This question is for a program in Java.

In the traditional English system of measurement, each inch on a ruler is marked off into fractions using tick marks that look like this:

image text in transcribed

The longest tick mark divides the inch into halves, two shorter tick marks indicate the quarter divisions, and even shorter ones mark the eighths, sixteenths and so on. Write a recursive method drawRuler to draw this. The method is given the coordinates for a rectangle in which to draw the ruler. The method draws a sequence of vertical tick marks. The center tick mark is half the height of the rectangle in which it's drawn. Each smaller tick mark is half the height of the next larger one. Once the tick marks become sufficiently small (say 2 pixels), the recursion terminates. The idea is to recognize that the middlemost tick mark subdivides the rectangle into two smaller rectangles, each of which is a smaller ruler of its own.

Ruler Viewer Ruler Viewer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions