Advertisement
operationBirdNet

readme.txt -- for number-display-ss

Aug 28th, 2015
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.43 KB | None | 0 0
  1. readme.txt -- for number-display-ss
  2.  
  3. THE TASK
  4.  
  5. The spreadsheet displays numbers at full resolution, but this means a
  6. number with more than 8 or 9 digits is not fully visible in the text
  7. box. Modify the spreadsheet program so that numbers are displayed in cells
  8. with at most 8 characters. Use scientific notation and rounding as necessary.
  9. Hint: The 'g' conversion in the Java Formatter class might be helpful.
  10. REED'S NOTES:
  11. 1) Full Resolution: Translation?
  12. 2) *MORE THAN* 8 or 9 digits is *NOT* fully visible
  13. 3) *MODIFIY*...numbers...in cells...at *MOST* 8 characters
  14. 4) Scientific Notation: way of writing numbers that are too big or,
  15. too small to be conveniently written in decimal form.
  16. 5) Formatter: An interpreter for printf-style format strings.
  17. This class provides support for layout justification and alignment,
  18. common formats for numeric, string, and date/time data,
  19. and locale-specific output. Common Java types such as byte,
  20. BigDecimal, and Calendar are supported. Limited formatting
  21. customization for arbitrary user types is provided through
  22. the Formattable interface.
  23.  
  24. Even if rounding is needed to display a number in a cell, all
  25. computation should use the full precision of every formula and value.
  26. Since the displayed values will be truncated, you will need a new
  27. instance variable in the Cell class to hold the full-precision value
  28. of the cell in case a formula references it. When a cell holds a
  29. formula, it is displayed in the formula bar. If the cell does not hold
  30. a formula, the full-precision value of the cell should be displayed
  31. and editable in the formula bar, even if the spreadsheet table shows a
  32. truncated version of the value.
  33. REED'S NOTES:
  34. 1) full precision: Translation?
  35. 2) *NEED* new *INSTANCE VARIABLE* in *Cell class*
  36. to hold the *full-precision value* of
  37. cell in case a formula *references it*:
  38. EX: Translation?
  39.  
  40. 3) Cell holds formula -> full-precision value -> displayed -> formula bar
  41. EX: Translation?
  42. 4) Cell *NOT* holds formula -> full-precision value
  43. -> displayed & editable -> formula bar -> even if -> table shows
  44. -> truncated version value.
  45. EX: Translation?
  46.  
  47. If a number is entered with 8 or fewer characters, it should not be
  48. reformatted; for example, if the user enters 123, the spreadsheet should not
  49. change the display to 123.0000.
  50. REED'S NOTES:
  51. 1) number -> 8 or fewer -> *NOT* reformatted
  52.  
  53. Spreadsheet cells can also display text that cannot be parsed as a number.
  54. Nonnumber data should appear in cells without modification, even though
  55. not all characters will be visible at once.
  56. REED'S NOTES:
  57. 1) Nonnumber data -> appear -> in cells -> without modification
  58.  
  59. Video demonstrations of a solution for this task are available.
  60. 1. During the exam: as number-display-solution-demo.html in the "Solution Demonstration Videos"
  61. folder on the desktop in the exam delivery environment.
  62. 2. During exam preparation, outside the exam environment.
  63. https://s3-us-west-2.amazonaws.com/proxor-video/video/number-display-solution-demo-transcoded.mp4
  64.  
  65. REED'S NOTES:
  66.  
  67. ***SCIENTIFIC NOTATION***
  68.  
  69. 1) can display numbers in scientific notation using java.text package.
  70. Specifically DecimalFormat class in java.text package.
  71.  
  72. EX:
  73.  
  74. import java.text.*;
  75. import java.math.*;
  76.  
  77. public class TestScientific {
  78.  
  79. public static void main(String args[]) {
  80. new TestScientific().doit();
  81. }
  82.  
  83. public void doit() {
  84. NumberFormat formatter = new DecimalFormat();
  85.  
  86. int maxinteger = Integer.MAX_VALUE;
  87. System.out.println(maxinteger); // 2147483647
  88.  
  89. formatter = new DecimalFormat("0.######E0");
  90. System.out.println(formatter.format(maxinteger)); // 2,147484E9
  91.  
  92. formatter = new DecimalFormat("0.#####E0");
  93. System.out.println(formatter.format(maxinteger)); // 2.14748E9
  94.  
  95.  
  96. int mininteger = Integer.MIN_VALUE;
  97. System.out.println(mininteger); // -2147483648
  98.  
  99. formatter = new DecimalFormat("0.######E0");
  100. System.out.println(formatter.format(mininteger)); // -2.147484E9
  101.  
  102. formatter = new DecimalFormat("0.#####E0");
  103. System.out.println(formatter.format(mininteger)); // -2.14748E9
  104.  
  105. double d = 0.12345;
  106. formatter = new DecimalFormat("0.#####E0");
  107. System.out.println(formatter.format(d)); // 1.2345E-1
  108.  
  109. formatter = new DecimalFormat("000000E0");
  110. System.out.println(formatter.format(d)); // 12345E-6
  111. }
  112. }
  113.  
  114. REED'S NOTES:
  115.  
  116. ***'g' conversion***
  117.  
  118. Conversions are divided into the following categories:
  119.  
  120. GENERAL - may be applied to any argument type
  121.  
  122. CHARACTER - may be applied to basic types which represent Unicode characters:
  123. char, Character, byte, Byte, short, and Short.
  124. This conversion may also be applied to the types int and Integer when Character.isValidCodePoint(int) returns true
  125.  
  126. NUMERIC:
  127. INTEGRAL - may be applied to Java integral types: byte, Byte, short, Short, int and Integer, long, Long, and BigInteger
  128. FLOATING POINT - may be applied to Java floating-point types: float, Float, double, Double, and BigDecimal
  129.  
  130. DATE/TIME - may be applied to Java types which are capable of encoding a date or time: long, Long, Calendar, and Date.
  131.  
  132. PERCENT - produces a literal '%' ('\u0025')
  133.  
  134. LINE SEPARATOR - produces the platform-specific line separator
  135.  
  136. The following table summarizes the supported conversions.
  137. Conversions denoted by an upper-case character (i.e. 'B', 'H', 'S', 'C', 'X', 'E', 'G', 'A', and 'T')
  138. are the same as those for the corresponding lower-case conversion characters except that
  139. the result is converted to upper case according to the rules of the prevailing Locale.
  140. The result is equivalent to the following invocation of String.toUpperCase()
  141. out.toUpperCase()
  142.  
  143. CONVERSION | ARGUMENT | CATEGORY DESCRIPTION
  144. 'b', 'B'| general | If the argument arg is null, then the result is "false". If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(arg). Otherwise, the result is "true".
  145.  
  146. 'h', 'H'| general | If the argument arg is null, then the result is "null". Otherwise, the result is obtained by invoking Integer.toHexString(arg.hashCode()).
  147.  
  148. 's', 'S' | general | If the argument arg is null, then the result is "null". If arg implements Formattable, then arg.formatTo is invoked. Otherwise, the result is obtained by invoking arg.toString().
  149.  
  150. 'c', 'C' | character | The result is a Unicode character
  151.  
  152. 'd' | integral | The result is formatted as a decimal integer
  153.  
  154. 'o' | integral | The result is formatted as an octal integer
  155.  
  156. 'x', 'X' | integral | The result is formatted as a hexadecimal integer
  157.  
  158. 'e', 'E' | floating point | The result is formatted as a decimal number in computerized scientific notation
  159.  
  160. 'f' | floating point | The result is formatted as a decimal number
  161.  
  162. ***'g', 'G' | floating point | The result is formatted using computerized scientific notation or decimal format, depending on the precision and the value after rounding.***
  163.  
  164. 'a', 'A' | floating point | The result is formatted as a hexadecimal floating-point number with a significand and an exponent
  165.  
  166. 't', 'T' | date/time | Prefix for date and time conversion characters. See Date/Time Conversions.
  167.  
  168. '%' | percent | The result is a literal '%' ('\u0025')
  169.  
  170. 'n' | line separator | The result is the platform-specific line separator
  171.  
  172. Any characters not explicitly defined as conversions are illegal and are reserved for future extensions.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement