Im try to create a java program that checks to see if a give

Im try to create a java program that checks to see if a given boolean expression is a tautology or not

my code so far is as follows:

public static class TreeNode

   {

       char data;

       TreeNode left;

       TreeNode right;

      

       TreeNode(char item)

       {

           data = item;

           left = null;

           right = null;

       }

   }

public static class Tree

   {

       boolean operator(char x) // if isUpperCase

       {

           if(Character.isUpperCase(x))

           {

               return true;

           }

       return false;

   }

      

TreeNode buildTree(char s[])

{

   Stack<TreeNode> stack = new Stack();

   TreeNode tN;

   TreeNode tN1;

   TreeNode tN2;

  

  

   for(int i = 0; i < s.length; i++)

   {

       if(!operator(s[i]))

       {

           tN = new TreeNode(s[i]);

           stack.push(tN);

       }

       else

       {

           tN = new TreeNode(s[i]);

          

           tN1 = stack.pop();

           tN2 = stack.pop();

           tN.right = tN1;

           tN.left = tN2;

           stack.push(tN);

       }

      

   }

tN = stack.peek();

return tN;

}

  

public void printTree(TreeNode tN)

{

   if(tN != null)

   {

       printTree(tN.left);

       System.out.print(tN.data);

       printTree(tN.right);

   }

}

//Evaluate/Solve

//To do....

  

  

} //End of Tree Class

public static void main(String[] args)

{

   Tree newTree = new Tree();

   Scanner keyboard = new Scanner(System.in);

   System.out.println(\"Please enter a postfix expression:\"); //Example: ppO

   String s = keyboard.nextLine();

   char[] array = s.toCharArray();

   TreeNode trNode = newTree.buildTree(array);

   newTree.printTree(trNode);

  

}

}  

  

  

  

Solution

static void Main() { Console.Write(\"Enter a character: \"); char c = (char)Console.Read(); if (Char.IsLetter(c)) { if (Char.IsLower(c)) { Console.WriteLine(\"The character is lowercase.\"); } else { Console.WriteLine(\"The character is uppercase.\"); } } else { Console.WriteLine(\"Not an alphabetic character.\"); } } }
Im try to create a java program that checks to see if a given boolean expression is a tautology or not my code so far is as follows: public static class TreeNod
Im try to create a java program that checks to see if a given boolean expression is a tautology or not my code so far is as follows: public static class TreeNod
Im try to create a java program that checks to see if a given boolean expression is a tautology or not my code so far is as follows: public static class TreeNod

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site