import java.util.Scanner;
public class Vending {
public double vend(double balance) {
Scanner in = new Scanner(System.in);
balance = 0;
System.out.print("Enter a command = ");
String command = in.nextLine();
while (in.hasNext()) {
if (command.equals("penny")) {
balance = balance + 0.01;
System.out.println("balance = " + balance);
}
return balance;
}
}
}
Hi! I have tried everything to figure out why the return statement is not being recognized. If I put the "return balance" anywhere else it says that the system.out.println is unreachable... Can any of you kindly help me out as to why this may not be working?? Thank you!!