Write a method that takes an array of integers and a


Assignment

Consider an interface
public interface NumberFormatter
{
String format (in n);
}
Provide four classes that implement this interface. A DefaultFormatter formats an integer in the usual way. A DecimalSeparatorFormatter formats an integer with decimal separators; for example, one million as 1,000,000. An AccountingFormatter formats negative numbers with
parenthesis; for example, -1 as (1). A BaseFormatter formats the number as base n, where n is any number between 2 and 36 that is provided in the constructor.

Write a method that takes an array of integers and a NumberFormatter object and prints each number on a separate line, formatted with the given formatter. The numbers should be right aligned.

Provide a test class that shows the program working with an array of numbers.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a method that takes an array of integers and a
Reference No:- TGS02361261

Now Priced at $10 (50% Discount)

Recommended (99%)

Rated (4.3/5)