Добавил:
Upload
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабы по 2 RKG с нета / ПО сетей ЭВМ / Лаб_2 / HelloDate / src / HelloDate
.java import java.io.*;
class compute
{
public double a = 0;
public double b = 0;
public double c = 0;
public double d = 0;
};
class Tabulate {
public void Calc() throws Exception {
double y = 0;
double x=0;
double min=0;
double max=0;
double tab=0;
compute cc= new compute();
BufferedReader in;
in = new BufferedReader(new FileReader("in.txt"));
BufferedWriter out;
out = new BufferedWriter(new FileWriter("out.txt"));
String s;
try {
while ((s = in.readLine()) != null) {
String[] ss = s.split("\t");
cc.a = Double.parseDouble(ss[0]);
cc.b = Double.parseDouble(ss[1]);
cc.c = Double.parseDouble(ss[2]);
cc.d = Double.parseDouble(ss[3]);
min = Double.parseDouble(ss[4]);
max = Double.parseDouble(ss[5]);
tab = Double.parseDouble(ss[6]);
x = min;
while ( x <=max )
{
y=cc.a*x*x+cc.b*x+cc.c*(1.0/(x*x))+cc.d;
System.out.print("tabulate x=");
out.write("tabulate x=");
System.out.print(x);
out.write(Double.toString(x));
System.out.print(" y=");
out.write(" y=");
System.out.println(y);
out.write(Double.toString(y));
out.write("\n\n");
x=x+tab;
};
System.out.println("\n");
}
in.close();
out.close();
} catch (IOException eee) {
}
}
};
public class HelloDate {
public static void main(String[] args) {
Tabulate tab = new Tabulate();
try {
tab.Calc();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
class compute
{
public double a = 0;
public double b = 0;
public double c = 0;
public double d = 0;
};
class Tabulate {
public void Calc() throws Exception {
double y = 0;
double x=0;
double min=0;
double max=0;
double tab=0;
compute cc= new compute();
BufferedReader in;
in = new BufferedReader(new FileReader("in.txt"));
BufferedWriter out;
out = new BufferedWriter(new FileWriter("out.txt"));
String s;
try {
while ((s = in.readLine()) != null) {
String[] ss = s.split("\t");
cc.a = Double.parseDouble(ss[0]);
cc.b = Double.parseDouble(ss[1]);
cc.c = Double.parseDouble(ss[2]);
cc.d = Double.parseDouble(ss[3]);
min = Double.parseDouble(ss[4]);
max = Double.parseDouble(ss[5]);
tab = Double.parseDouble(ss[6]);
x = min;
while ( x <=max )
{
y=cc.a*x*x+cc.b*x+cc.c*(1.0/(x*x))+cc.d;
System.out.print("tabulate x=");
out.write("tabulate x=");
System.out.print(x);
out.write(Double.toString(x));
System.out.print(" y=");
out.write(" y=");
System.out.println(y);
out.write(Double.toString(y));
out.write("\n\n");
x=x+tab;
};
System.out.println("\n");
}
in.close();
out.close();
} catch (IOException eee) {
}
}
};
public class HelloDate {
public static void main(String[] args) {
Tabulate tab = new Tabulate();
try {
tab.Calc();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}