I am new to using java and am running into problems with creating a program that tells me if my input is a logical sentence. Here is what I have so far (I am sure there are a couple of mistakes):
public class propLogic {
String stringName;
public propLogic(string stringA){
stringName = stringA;
}
public static void main(String[] args) {
propLogic one = new propLogic("hello");
if (stringName.equals("p")) {
System.out.println("Valid logical sentence");
} else if (stringName.equals("~p")) {
System.out.println("Valid logical sentence");
} else if (stringName.equals("p & v")) {
System.out.println("Valid logical sentence");
} else {
System.out.println("Not a valid logical sentence");
}
}
}
Aucun commentaire:
Enregistrer un commentaire