i am trying to do like a console where you can change a variable by saying yes or no, and for some reason one of my Boolean (auto) variables are being set to true even when it should be defaulted to false here is the code:
import java.util.Scanner;
public class Digital {
public static void main(String[] args) {
boolean ignite = false;
boolean heatup = false;
boolean dispose = false;
boolean alertwick = false;
boolean auto = false;
boolean candlewick = false;
boolean off = false;
boolean ready = false;
boolean swich = false;
System.out.println("consol- set circumstances of the candle");
Scanner myObj = new Scanner(System.in);
System.out.println("is the switch on?");
String consolswich = myObj.nextLine();
if (consolswich.equals("yes")) {
swich = true;
} else {
}
System.out.println("is the candle ready?(in auto)");
String consolready = myObj.nextLine();
if (consolready.equals("yes")) {
ready = true;
} else {
}
System.out.println("is auto on?");
String consolau = myObj.nextLine();
if (consolau.equals("yes")) {
auto = !auto;
} else {
}
System.out.println("are there any wicks left?");
String consolwick = myObj.nextLine();
if (consolwick.equals("yes")) {
candlewick = true;
} else {
}
System.out.println("how long is the candlewick?(whole number, cm)");
int consollength = myObj.nextInt();
int candleheight = consollength;
if (auto = true) {
System.out.println("ballin");
if ((swich = true) && (auto = false)) {
if (candleheight < 1) {
dispos开发者_运维问答e = true;
System.out.println("candlewick disposed");
}
if (candlewick = false) {
alertwick = true;
System.out.println("user as been alerted to the lack of candlewicks");
} else {
heatup = true;
System.out.println("the candle has been formed and then ignited");
}
} else {
System.out.println("nothing happened/error");
}
} else {
while (auto = true) {
if (ready = true)
{
ignite = true;
System.out.println("the candle has been lit");
break;
} else {
if (candleheight == 0) {
dispose = true;
System.out.println("candlewick has been disposed of");
}
if (candlewick = false) {
alertwick = true;
System.out.println("user has been alerted to the lack of candlewicks");
break;
} else {
System.out.println("the candle has been formed");
ready = true;
}
}
}
}
}
}
i have tried different ways of changing the boolean, and i know all the other parts work, the other variables work when auto is removed, but it is a necessary part of the program so i cant remove it
精彩评论