errors that puzzle me
hi i am new to java and i have a problem with my code i am writing code and i am using decimal format to overload and improve a method.
import java.io.*;
public class Desk{
private static DeskItem[] desk = new DeskItem[10];
private static int lastIndex = -1;
private static String TxtFile = "Test2.txt";
private static final char DELIM = '\t';
private static PrintWriter out;
private static BufferedReader in;
public static void main(String[] args){
//1> declare an array of 10 objects of type DeskItem
//2> declare any other variables that you need to maintain
//the array.
//4> Construct the following items and use the addItem method to
//add them to the array:
//Note that no keyboard input is required - just hard-code
addItem(new Pencil("blue",2, 8.00));
addItem(new Stapler(12,25.0));
addItem(new Highlighter(1.50,"yellow"));
addItem(new Pencil("green", 5, 0.50));
addItem(new Stapler(10,5.00));
addItem(new Highlighter(1.20,"orange"));
addItem(new Pencil("red",10,2.00));
//add stapler with 25 staples worth $12
//a yellow highlighter worth $1.50
//a green 5cm pencil worth 50c
//a stapler with 10 staples worth $5.00
//an orange highlighter worth $1.20
//a red 10cm pencil worth $2
}
private static void addItem(DeskItem item){
lastIndex++;
desk[lastIndex] = item;
}
//3> code a method with the signature addItem(DeskItem item)
//that will add the item to the next available spot in the array
//This method should do nothing if the array is full.
//5> Add a method named display that prints all the items
//Call the display method from main
//NumberFormat df;
private static void display(){
for(int i= 0;i <desk.length; i++){
System.out.println(desk);
}
}
//6> Overload the display method to accept a parameter of type double
//This version should only display items that cost the given amount
//or greater.
private static void display(double minPrice){
System.out.println("The items above" +DeskItem.df.format(minPrice));
for(int i= 0;i<=lastIndex; i++){
if(desk.getPrice() >=minPrice){
System.out.println(desk);
}
}
}
here is the output error i get when trying to successfully use df.format
:E:\practice test\Desk.java:65: cannot resolve symbol
symbol : variable df
location: class DeskItem
System.out.println("The items above" + DeskItem.df.format(minPrice));
^
1 error
Process completed.
anyone know how to fix this error i have tried many things and when i declare a decimal format i get a logical error as it compiles yet gives know output.

