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:
Code :
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 :((
Re: Please help me with this Java programming
what's your problem here?
Re: Please help me with this Java programming
Code :
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..^^,
Re: Please help me with this Java programming
first let me know what you are trying to do
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.