I have this program that I'm writing that mainly runs similar to a simple choose your own adventure game. It's a trouble shooting guide for rocketry, that mainly for personal use. It has simple value inputs, y/n, a,b,c,d, and so on. After a few different segments I decided to ask the user (incase I give it to friends or something) if they would like to hear a tip, if they said yes, the tip would be printed out, if not, the program would continue running. When I tested it, i got the error message: 'bash y: command not found'.
All of the syntax is correct (that was the best answer I could find to try to correct the problem, didn't apply), and I don't know what bash is, and I'm using replit, incase that matters. I get this error in two different areas, but here is an example of one:
//problem code
class A{
public static void tip(){
Scanner scan = new Scanner(System.in);
System.out.println("Would you like to hear a tip? (y/n)");
String tipA = scan.nextLine();
if (tipA.equals("y")){
System.out.println("blahblahblah");
}
}
}
//there was a typo in this post but not in the actual code, wish it was the actual problem, thanks for pointing it out
Then I changed it to this:
//the 'fixed' code
class A{
public static void tip(){
Scanner scan = new Scanner(System.in);
System.out.println("Would you like to hear a tip? (y(1)/n(2))");
int tipA = scan.nextInt();
if (tipA == 1){
System.out.println("blahblahblah");
}
}
}
It works, but as you can see in the 'fixed' code, the y/n doesn't look as nice, and I am also curious as to why, because I could not find any answers pertaining to this scenario. The other area is similar, but instead of "y/n", it is 'A, B, C, D' choices. I have my current workaround, but it would be nice to have a solution to polish the program a bit.
Any help is much appreciated.