<h3>Please help me to program a code that will plot (graph) COMPLEX TRIGONOMETRIC FUNCTIONS recognizing the input from the user as string
Printable View
<h3>Please help me to program a code that will plot (graph) COMPLEX TRIGONOMETRIC FUNCTIONS recognizing the input from the user as string
You first.
Please show us what you've tried and what problems you may be having with it.
Sure thing. What do you need help with?Quote:
Please help me
Generally speaking if you need help, then you have a problem to solve. What is the problem and what is your problem with the problem?
I'm deleting your second thread. Please do not ask folks here to "mail me" a solution. This is not a "do my homework for me site".
--- Update ---
I have received this private message from the original poster which for his benefit I am posting here:
Quote:
i m new for java,my java skill is not that good and this is all i've done yet,and no idea what to do next
Code :import java.util.Scanner; import java.util.Stack; class Tokenizer { private String inputc; private String med = ""; public void tokenize (String a){ inputc = a; int c=0; int c1=0; for(int i=0;i < inputc.length();i++) { if(inputc.charAt(i)=='(') c++; else if(inputc.charAt(i)==')') c1++; } if(c!=c1) { System.out.println("This is incorrect string, please check your input"); } else { String str = ""; String[] fun={"sin","cos","tan","cosec","sec","cot"}; Stack<String> stack = new Stack<String>(); Stack<String> stack1 = new Stack<String>(); for (int i = 0; i < inputc.length(); i++){ str = inputc.substring(i,i+1); if(str.matches("fun")) { med = str; stack1.push(med); } else if (foundOperator(str)){ if (stack.isEmpty()){ stack1.push(str); } else{ String stackTop = stack.peek(); while (getPrecedence(stackTop,str).equals(stackTop) && !(stack.isEmpty())){ med = stack.pop(); stack1.push(med); if (!(stack.isEmpty())) stackTop = stack.peek(); } stack1.push(str); } } } while(!(stack.isEmpty())) { med = stack.pop(); stack1.push(med); } while (!stack1.isEmpty()) { System.out.print(stack1.peek() + " "); stack1.pop(); } } private boolean foundOperator(String ch){ String operators = "*/%+-"; if (operators.indexOf(ch) != -1) return true; else return false; } private String getPrecedence(String op1, String op2){ String multiplicativeOps = "*/%"; String additiveOps = "+-"; if ((multiplicativeOps.indexOf(op1) != -1) && (additiveOps.indexOf(op2) != -1)) return op1; else if ((multiplicativeOps.indexOf(op2) != -1) && (additiveOps.indexOf(op1) != -1)) return op2; else if((multiplicativeOps.indexOf(op1) != -1) && (multiplicativeOps.indexOf (op2) != -1)) return op1; else return op1; } } } class Complex_Trigonometry { public static void main(String[] args) { System.out.println("Enter the trigonometric function which is to be plotted:-"); Scanner scanner = new Scanner(System.in); String input = scanner.nextLine(); Tokenizer t = new Tokenizer(); t.tokenize(input); } }