Question
I'm having a problem with java GUI class is not compiling, needs urgent answer /** * */ /** * @author rrtt4 * */ package pckg1;
I'm having a problem with java GUI class is not compiling, needs urgent answer
/**
*
*/
/**
* @author rrtt4
*
*/
package pckg1;
import java.util.Stack;
import java.util.StringTokenizer;
import java.awt.*;
import java.awt.event.*;
import java.time.temporal.ValueRange;
import javax.swing.*;
public class MyInfixProj{
@SuppressWarnings({ "rawtypes", "unchecked" })
public String Infix( String express, Stack operatorStack){
String Str;
String tokens = null;
//Remove space in the expression
express= express.replaceAll("\\s+","")+ "=";
String operator= "()*/ +-=";
//StringTokenizer tokens = new StringTokenizer(express,operator, true);
while(tokens.hasMoreToken()){
String[] tkn = tokens.nextToken();
if(operator.indexOf(tokens)< 0);
Stack valueStack = null;
valueStack.push(tokens);
//else
operator.push(tokens);
}
return result;
}
//Resolve Operations
//java.util.Stack valueStack;
resolve(valueStack,operatorStack);
}
}
//private void push(StringTokenizer tokens) {
// TODO Auto-generated method stu
public int getPriority(String op){
if (op.equals("(")|| op.equals(")")) {
return 0;
} else if(op.equals("*")|| op.equals("/")) {
return 2;
} else if(op.equals("=")) {
return 3;
}
return Integer.MIN_VALUE;
}
@SuppressWarnings("unchecked")
public void resolve(Stack Values,Stack operators){
while(operators.size()>=2){
String first=(String)operators.pop();
String second=(String)operators.pop();
if(getPriority(first) operators.push(second); operators.push(first); return; } else{ String firstValue=(String)Values.pop(); String secondValue=(String)Values.pop(); Values.push(getResults(secondValue,second,firstValue)); operators.push(first); } } } private Object getResults(String secondValue, String second, String firstValue) { // TODO Auto-generated method stub return null; } public String fetResults(String operand1,String operator, String operand2){ int op1=Integer.parseInt(operand1); int op2=Integer.parseInt(operand2); switch (operator) { case "*": return ""+(op1*op2); case "/": return ""+(op1/op2); case "+": return ""+(op1+op2); case "-": return ""+(op1-op2); default: return null; } } } //---------------------- /** * */ /** * @author rrtt4 * */ package pckg1; import java.util.Stack; import java.util.StringTokenizer; import java.awt.*; import java.awt.event.*; import java.time.temporal.ValueRange; import javax.swing.*; public class MyInfixProj{ @SuppressWarnings({ "rawtypes", "unchecked" }) public String Infix( String express, Stack operatorStack){ String Str; String tokens = null; //Remove space in the expression express= express.replaceAll("\\s+","")+ "="; String operator= "()*/ +-="; //StringTokenizer tokens = new StringTokenizer(express,operator, true); while(tokens.hasMoreToken()){ String[] tkn = tokens.nextToken(); if(operator.indexOf(tokens)< 0); Stack valueStack = null; valueStack.push(tokens); //else operator.push(tokens); } return result; } //Resolve Operations //java.util.Stack valueStack; resolve(valueStack,operatorStack); } } //private void push(StringTokenizer tokens) { // TODO Auto-generated method stu public int getPriority(String op){ if (op.equals("(")|| op.equals(")")) { return 0; } else if(op.equals("*")|| op.equals("/")) { return 2; } else if(op.equals("=")) { return 3; } return Integer.MIN_VALUE; } @SuppressWarnings("unchecked") public void resolve(Stack Values,Stack operators){ while(operators.size()>=2){ String first=(String)operators.pop(); String second=(String)operators.pop(); if(getPriority(first) operators.push(second); operators.push(first); return; } else{ String firstValue=(String)Values.pop(); String secondValue=(String)Values.pop(); Values.push(getResults(secondValue,second,firstValue)); operators.push(first); } } } private Object getResults(String secondValue, String second, String firstValue) { // TODO Auto-generated method stub return null; } public String fetResults(String operand1,String operator, String operand2){ int op1=Integer.parseInt(operand1); int op2=Integer.parseInt(operand2); switch (operator) { case "*": return ""+(op1*op2); case "/": return ""+(op1/op2); case "+": return ""+(op1+op2); case "-": return ""+(op1-op2); default: return null; } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started