Question: Consider an interface public interface NumberFormatter String format (int n); Provide four classes that implement this interface as follows: A DefaultFormatter formats an integer in

Consider an interface public interface NumberFormatter String format (int n); Provide four classes that implement this interface as follows: 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 parentheses; for example, -1 as (1). A BaseFormatter formats the number in base n, where n is any number between 2 and 16, that is provided in thc constructor Also, provide a tester class, Formatrester, that tests above classes using various integer values read from an input file, Numbers.txt, and creates an output file, FormattedNumbers.txt, and add the formatted numbers into it. For instance if the input file contains: 5 -10000 1000000 36 Then output file, based on the methods you call for these numbers, can contain something like: Default Format: 5 -10000 1000000 36 Decimal Format: 5 -10,000 1,000,000 36 Accounting Format: 5 (10000) 1000000 36 Base 8 Format: 5 -23420 3641100 44 Base 2 Format: 101 -10011100010000 11110100001001000000 100100 Consider an interface public interface NumberFormatter String format (int n); Provide four classes that implement this interface as follows: 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 parentheses; for example, -1 as (1). A BaseFormatter formats the number in base n, where n is any number between 2 and 16, that is provided in thc constructor Also, provide a tester class, Formatrester, that tests above classes using various integer values read from an input file, Numbers.txt, and creates an output file, FormattedNumbers.txt, and add the formatted numbers into it. For instance if the input file contains: 5 -10000 1000000 36 Then output file, based on the methods you call for these numbers, can contain something like: Default Format: 5 -10000 1000000 36 Decimal Format: 5 -10,000 1,000,000 36 Accounting Format: 5 (10000) 1000000 36 Base 8 Format: 5 -23420 3641100 44 Base 2 Format: 101 -10011100010000 11110100001001000000 100100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
