Posted: Sat Aug 14, 2004 1:07 am Post subject: BufferedReader problem.
The interpreter brings back 3 errors involving the BufferedReader in the PieStore class. Cannot resolve symbols.
code:
class Pie {
String flavour;
int slices;
double price;
public void addFlavour(String f) {
flavour = f;
}
public void addSlices(int s) {
slices = s;
}
public void addPrice(double p) {
price = p;
}
public String showPrices() {
return "you can by a " + flavour + " pie with " + slices + " slices for " +
price;
}
}
// Main class
class PieStore {
public static void main (String[] args) {
Pie pieOB = new Pie();
BufferedReader reader = new BufferedReader(new
InputStreamReader(System.in));
System.out.println("What flavour of pie would you like to add to the
store's inventory?");
pieOB.addFlavour(reader.readLine());
System.out.println("How many slices are in this particular pie?");
pieOB.addSlices(Integer.parseInt(reader.readLine()));
System.out.println("How much will this pie cost?");
pieOB.addPrice(Double.parseDouble(reader.readLine()));
System.out.println(pieOB.showPrices());
}
}
Help always appreciated. Thanks.
Sponsor Sponsor
Dan
Posted: Sat Aug 14, 2004 10:40 am Post subject: (No subject)
Did you inculde the api that has BufferedReader in it? I think that it is java.io.* you need to use BufferedReader.
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!