This is a pretty common problem I run into when I'm programming, and I'm a beginner so it stumps me for whatever reason. Here's my code:
boolean valid = false;
do {
double newPrice;
System.out.print("Enter new price: $");
newPrice = scan.nextDouble();
if(newPrice > 0){
b[bookChosen].price() = new newPrice;
valid = true;
}
}while(!valid);
The newPrice double in the if-statement cannot be found, and I know why, I just can't think of a way to be able to see if the user's input is a viable number.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire