Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is supposed to be programmed using Java Consider an interface public interface NumberFormatter String format (int n) Provide four classes that implement this interface.

image text in transcribedThis is supposed to be programmed using Java
Consider an interface public interface NumberFormatter String format (int 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 called FormatintsTest.java that shows the program working with an array of numbers. Use the numbers 8, 100,-10, 45, 0 as your test values in the array. Show all four formatters working with the array. Use 20 for n for the BaseFormatter. Consider an interface public interface NumberFormatter String format (int 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 called FormatintsTest.java that shows the program working with an array of numbers. Use the numbers 8, 100,-10, 45, 0 as your test values in the array. Show all four formatters working with the array. Use 20 for n for the BaseFormatter

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

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago