![]() |
The Java Programming Language |
![]() |
Objectives: | At the conclusion of
this lab students should:
|
Background: | This lab will have students work with formatting and mathematical operations in Java. |
New Terms: |
|
Materials: |
Use these two "starter programs". |
Prerequisites: | No prerequisites to this lab. |
Acknowledgement:: | Lab adapted from a lab by Mike Norton and Lewis and Loftus. |
Turning in your work: |
See your instructor for specific instructions for turning in your work or getting credit for this lab. |
NumberFormat is another class that provides formatting objects. It contains a method that returns a complete object in money format. This method is named getCurrencyInstance() and the documentation for this method is shown below. You do not need to make a "new" number format, but instead can call this method with the call NumberFormat.getCurrencyInstance() just like you might call Math class methods. NumberFormat also has a format method that works just like the DecimalFormat class does.
static NumberFormat | getCurrencyInstance()
Returns a currency format for the current default locale. |
***** CS Deli ***** Unit Price: $4.25 per pound Weight: 2.56 pounds TOTAL: $10.89Part C: Distance The file Distance.java contains an incomplete program to compute the distance between two points. Recall from math that the distance between the two points (x1, y1) and (x2, y2) is computed by taking the square root of the quantity (x1 – x2) 2 + (y1 – y2) 2 The program already has code to get the two points as input. For some helpful methods, go to the Resources tab on Canvas and open the document labelled Math Class methods. Math is a class that provides helpful math funtions. To use the function, you do not need an object....you simply use Math.xxxxx() where xxxxx() is the name of the method passing whatever value you need.
Updated 09/22/14 (nlh)