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.

Results 1 to 4 of 4

Thread: <b>TRIGONOMETRIC FUNCTION GRAPHING</b>

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default <b>TRIGONOMETRIC FUNCTION GRAPHING</b>

    <h3>Please help me to program a code that will plot (graph) COMPLEX TRIGONOMETRIC FUNCTIONS recognizing the input from the user as string


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: <b>TRIGONOMETRIC FUNCTION GRAPHING</b>

    You first.

    Please show us what you've tried and what problems you may be having with it.

  3. #3
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: <b>TRIGONOMETRIC FUNCTION GRAPHING</b>

    Please help me
    Sure thing. What do you need help with?
    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?

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: <b>TRIGONOMETRIC FUNCTION GRAPHING</b>

    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);
    }
     
     
    }

Similar Threads

  1. Distance function help
    By abf617 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 2nd, 2012, 06:32 PM
  2. class function
    By huddo in forum Object Oriented Programming
    Replies: 9
    Last Post: June 12th, 2012, 07:26 PM
  3. Function in Function?
    By junxiqqq in forum Java Theory & Questions
    Replies: 5
    Last Post: May 18th, 2012, 08:05 PM
  4. need help with a function...
    By fallout87 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 2nd, 2011, 05:42 AM
  5. Function of difference between two numbers
    By uplink600 in forum Java Theory & Questions
    Replies: 2
    Last Post: May 13th, 2009, 05:57 AM