Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 2 : Columnar output Write a complete Java program that starts by declaring four integer constants, and one boolean constant, with the following initial

Exercise 2: Columnar output
Write a complete Java program that starts by declaring four integer constants, and one boolean constant, with the following initial values:
final int START =;
final int END =10752;
final int INCREMENT =256;
final int COLUMNS =8;
final boolean RIGHT_JUSTIFY = true;
The program should print the numbers between START and END (inclusive), counting up by INCREMENT, in COLUMNS neatly-aligned columns of width 6 characters. The numbers in each column would either be left or right justified depending on RIGHT_JUSTIFY. The values above should produce output like this:
\table[[0,256,512,768,1024,1280,1536,1792],[2048,2304,2560,2816,3072,3328,3584,3840],[4096,4352,4608,4864,5120,5376,5632,5888],[6144,6400,6656,6912,7168,7424,7680,7936],[8192,8448,8704,8960,9216,9472,9728,9984],[10240,10496,10752,,,,,]]
*** End of program. ***
If RIGHT_JUSTIFY was false it would produce this:
\table[[0,256,512,768,1024,1280,1536,1792],[2048,2304,2560,2816,3072,3328,3584,3840],[4096,4352,4608,4864,5120,5376,5632,5888],[6144,6400,6656,6912,7168,7424,7680,7936],[8192,8448,8704,8960,9216,9472,9728,9984],[10240,10496,10752,,,,,]]
COMP 1020 Lab 1
End of program.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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