I was writing a program and I wasn't sure sure how to do letter b. I have the methods and constructor but I'm not sure how to format the float.

2. Create a class called Item.
a. Item will need instance variables itemID, itemName, inStore, and
Price (of types String, String, int and double accordingly).
b. Item will need appropriate methods and constructors. Make sure to have a
toString() method that prints the item, making sure to format the float to 2
decimal places with $.

This is what I have for the toString() method so far.

public String toString()
        return itemID + ": " + itemName + ", " + inStore + ", " + Price;
7 Years
Discussion Span
Last Post by JamesCherrill
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.