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 5 of 5

Thread: Please help me with this Java programming

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please help me with this Java programming

    Hello everyone I am a BSC Mathematics student and very beginner in Java Programming and as part of my Mathematics degree I am also learning Algorithm with Java programming. I am in very early stages of Java so I could be making very silly mistake but believe it or not but I am stuck with this error for last 2 days but still cannot figure out where is the problem. Anyone please help me I will really appreciate that.

    Following is the programme code I am using:
    import java.io.*;
    import javagently.*;
     
    class CW2Q1
    {
    	//Main program to run the Gaussian Quadrature.
     
    		   public static void main(String[] args) throws IOException
    			{
     
    					Gauss_Quadrature_Data = new Gauss_Quadrature_Data();
    					Gauss.input_data();
    					Gauss.cal_x();
    					Gauss.cal_fx();
    					Gauss.cal_sum();
    					Gauss.store_x_output();
    					Gauss.store_f_output();
     
    					BufferedReader user_keyin= Text.open(system.in);
     
    					System.out.print("What is your a");
    						int input_a = Text.readint(user_keyin);
    					System.out.print("What is your b");
    						int input_b = Text.readint(user_keyin);
    					System.out.print("What is your n");
    						int input_n = Text.readint(user_keyin);
    			}
     
     
    		static class Gauss_Quadrature_Data
    		{         
    			        double sum, x, fx;
    					int n=0; n<=3; n++;
     
    									 if (n==0); {
    										double [] []  t; c = new double[0.5773502692, -0.5773502692; 1.0000000000, 1.0000000000];
    									} else
    									if n==1); {
    									double [] [] t; c = new double[0.7745966692,	 0.0000000000, -0.7745966692; 0.5555555556, 0.8888888889, 0.5555555556];
    									}else
    									if (n==2); {
    										double [] [] t; c = new double[0.8611363116, 0.3399810436, -0.3399810436, -0.8611363116; 0.3478548451, 0.6521451549, - 0.6521451549, - 0.3478548451];
    									} else
    									if (n==3); {
    										double [] [] t; c =new double[0.9061798459, 0.5384693101, 0.0000000000, -0.5384693101, -0.9061798459;  0.2369268850, 0.4786286705, 0.5688888889, 0.4786286705, 0.2369268850];
    									 }
    		}
     
    		void input_data() throws IOException
    		{
    			//BufferedReader user_keyin = Text.open(System.in);
    			//System.out.print("User please key in the arraysize:");
    			BufferedReader user_file = Text.open("CW2Q1_data.txt");
    		}
     
    		void cal_x()
    		{
    				cal_x = ((b-a)*(double)(t)+b+a)/2;
    				return cal_x;
    		 }
     
    		void cal_fx()
    		{
    				cal_fx = Math.pow(x[t],2)*math.sin (x[t])*(b-a)/2;
    				return cal_fx;
    		}
     
    		void cal_sum()
    		{ // this section calculates the sum of a product c*fx
    			double cal_sum(double fx, double c)
    			 sum = 0.0;
    			double cal_sum = sum + (double)(c)*(double)(fx);
    			return cal_sum;
    		}
    }


    PLEASE HELP AS I NEED TO HAND THIS IN ON FRIDAY AND IT'S 50% OF MY ASSIGNMENT PLEASE HELP
    Last edited by helloworld922; March 10th, 2010 at 02:23 PM.


  2. #2
    Junior Member tina G's Avatar
    Join Date
    Mar 2010
    Location
    philippines
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Please help me with this Java programming

    what's your problem here?

  3. #3
    Junior Member tina G's Avatar
    Join Date
    Mar 2010
    Location
    philippines
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Please help me with this Java programming

    import java.io.*; 
     
    public class CW2Q1 {
     
        public static void main(String[] args)throws IOException {
        	Gauss_Quadrature_Data = new Gauss_Quadrature_Data();
    					Gauss.input_data();
    					Gauss.cal_x();
    					Gauss.cal_fx();
    					Gauss.cal_sum();
    					Gauss.store_x_output();
    					Gauss.store_f_output();
     
    					BufferedReader user_keyin= Text.open(system.in);
     
    					System.out.print("What is your a");
    						int input_a = Text.readint(user_keyin);
    					System.out.print("What is your b");
    						int input_b = Text.readint(user_keyin);
    					System.out.print("What is your n");
    						int input_n = Text.readint(user_keyin);
    			}
     
     
    		static class Gauss_Quadrature_Data
    		{         
    			        double sum, x, fx;
    				for (int n=0; n<=3; n++;){
    				}
     
    									 if (n==0) {
    										double [] []  t; c = new double[0.5773502692, -0.5773502692; 1.0000000000, 1.0000000000];
    									} else
    									if n==1) {
    									double [] [] t; c = new double[0.7745966692,	 0.0000000000, -0.7745966692; 0.5555555556, 0.8888888889, 0.5555555556];
    									}else
    									if (n==2) {
    										double [] [] t; c = new double[0.8611363116, 0.3399810436, -0.3399810436, -0.8611363116; 0.3478548451, 0.6521451549, - 0.6521451549, - 0.3478548451];
    									} else
    									if (n==3) {
    										double [] [] t; c =new double[0.9061798459, 0.5384693101, 0.0000000000, -0.5384693101, -0.9061798459;  0.2369268850, 0.4786286705, 0.5688888889, 0.4786286705, 0.2369268850];
    									 }
    		}
     
    		void input_data() throws IOException
    		{
    			//BufferedReader user_keyin = Text.open(System.in);
    			//System.out.print("User please key in the arraysize:");
    			BufferedReader user_file = Text.open("CW2Q1_data.txt");
    		}
     
    		void cal_x()
    		{
    				cal_x = ((b-a)*(double)(t)+b+a)/2;
    				return cal_x;
    		 }
     
    		void cal_fx()
    		{
    				cal_fx = Math.pow(x[t],2)*math.sin (x[t])*(b-a)/2;
    				return cal_fx;
    		}
     
    		void cal_sum()
    		{ // this section calculates the sum of a product c*fx
    			double cal_sum(double fx, double c)
    			 sum = 0.0;
    			double cal_sum = sum + (double)(c)*(double)(fx);
     
    		}
    }
     
    }

    here is my code for you.. I reduce some errors ?
    but Still It has an error..
    hope it little bit help you..^^,

  4. The Following User Says Thank You to tina G For This Useful Post:

    JavaPF (March 12th, 2010)

  5. #4
    Junior Member
    Join Date
    Jan 2010
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Please help me with this Java programming

    first let me know what you are trying to do

  6. #5
    Junior Member
    Join Date
    Jan 2010
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Please help me with this Java programming

    i think you just copied some where and posted it here, first you need to know the basics.

Similar Threads

  1. Is Java Programming Best?
    By messenger in forum Java IDEs
    Replies: 3
    Last Post: May 4th, 2010, 09:11 PM
  2. Please help me with this Java programming
    By simply_stunning79 in forum Algorithms & Recursion
    Replies: 1
    Last Post: February 22nd, 2010, 07:48 PM
  3. Towards java programming...
    By emigrant in forum Member Introductions
    Replies: 1
    Last Post: February 15th, 2010, 03:17 AM
  4. Please help me with this Java programming
    By simply_stunning79 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 14th, 2010, 06:42 AM
  5. Hello java programming forums
    By DnB in forum Member Introductions
    Replies: 2
    Last Post: February 9th, 2009, 07:38 AM