<h3>Please help me to program a code that will plot (graph) COMPLEX TRIGONOMETRIC FUNCTIONS recognizing the input from the user as string
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
<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?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:
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
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); } }