Course Hero Logo

ZyDE 5.4.1 Modifying IntegerWithBase to print bases greater than 10.pdf

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 2 out of 2 pages.

zyDE 5.4.1: Modifying IntegerWithBase to print bases greater than 10Define a new private method within IntegerWithBase called toAlphaNumDigit() that takes an integer value as an argument andreturns a char representing the digit. For argument values between 0 and 9, the method should simply return the unicode value forthat argument (i.e., a char value between 48 and 57). For argument values greater than or equal to 10, the method should returnunicode values corresponding to a lower-case letter in the alphabet(i.e., a char value between 97 and 122). Thus, the statementtoAlphaNumDigit(15);, for example, should return the char value 102, which corresponds to the letter "f".Use this private method to convert the remainder values computed within toString() to the appropriate characters. For example,creating the object IntegerWithBase tempNumInBase16 = new IntegerWithBase(255,16); should output "ff".public class IntegerWithBase {private int decimalValue;private int baseFormat;public IntegerWithBase(int inDecimal, int inBase) {this.decimalValue = inDecimal;this.baseFormat = inBase;}@Overridepublic String toString() {int quotientVal;int remainderVal;int dividendVal;

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 2 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Summer
Professor
N/A
Tags
Subroutine, Unicode

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture