Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ * * Convert.java * * TCSS 3 7 1 assignment 1 * / package code; / * * * A class to provide static
Convert.java TCSS assignment package code; A class to provide static methods for converting numbers between bases. @author Alan Fowler @author Arafa Mohamed @version public final class Convert A private constructor to inhibit instantiation of this class. private Convert Objects should not be instantiated from this class. This class is just a home for static methods functions This design is similar to the Math class in the Java language. Accepts an array of characters representing the bits in a two's complement number and returns the decimal equivalent. precondition: This method requires that the maximum length of the parameter array is postcondition: The value returned is the decimal equivalent of the two's complement parameter. The parameter array is unchanged. @param theBits an array representing the bits in a two's complement number @throws IllegalArgumentException if the length of the parameter array @return the decimal equivalent of the two's complement parameter public static int convertsCompToDecimalfinal char theBits Write code here to implement this function. Add comments, to explain any complex parts of your algorithm. return ; Replace the zero return value with a correct return value. Accepts a decimal parameter and returns an array of characters representing the bits in the bit two's complement equivalent. precondition: This method requires that the two's complement equivalent won't require more than bits postcondition: The returned array represents the bit two's complement equivalent of the decimal parameter. @param theDecimal the decimal number to convert to two's complement @throws IllegalArgumentException if the parameter cannot be represented in bits. @return a bit two's complement equivalent of the decimal parameter public static char convertDecimalTosCompfinal int theDecimal Write code here to implement this function. Add comments, to explain any complex parts of your algorithm. return null; Replace the null return value with a correct return value. NOTE: If you wish, you may also include private helper methods in this class.
Convert.java
TCSS assignment
package code;
A class to provide static methods for converting numbers between bases.
@author Alan Fowler
@author Arafa Mohamed
@version
public final class Convert
A private constructor to inhibit instantiation of this class.
private Convert
Objects should not be instantiated from this class.
This class is just a home for static methods functions
This design is similar to the Math class in the Java language.
Accepts an array of characters representing the bits in a two's complement number
and returns the decimal equivalent.
precondition:
This method requires that the maximum length of the parameter array is
postcondition:
The value returned is the decimal equivalent of the two's complement parameter.
The parameter array is unchanged.
@param theBits an array representing the bits in a two's complement number
@throws IllegalArgumentException if the length of the parameter array
@return the decimal equivalent of the two's complement parameter
public static int convertsCompToDecimalfinal char theBits
Write code here to implement this function.
Add comments, to explain any complex parts of your algorithm.
return ; Replace the zero return value with a correct return value.
Accepts a decimal parameter and returns an array of characters
representing the bits in the bit two's complement equivalent.
precondition:
This method requires that the two's complement equivalent
won't require more than bits
postcondition:
The returned array represents the bit two's complement equivalent
of the decimal parameter.
@param theDecimal the decimal number to convert to two's complement
@throws IllegalArgumentException if the parameter cannot be represented in bits.
@return a bit two's complement equivalent of the decimal parameter
public static char convertDecimalTosCompfinal int theDecimal
Write code here to implement this function.
Add comments, to explain any complex parts of your algorithm.
return null; Replace the null return value with a correct return value.
NOTE: If you wish, you may also include private helper methods in this class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started