Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

state two examples of positive science.

Answered: 1 week ago