Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ private boolean filter(double a) {
}

private int findMin() {
//todo реализовать
return 0;
for (int i = 1; ; i++){
double a = getA(i);
if (filter(a)){
return i;}
out.println(a);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Table {
public Table(double start, double end, double step) {

if (end <= start)
throw new RuntimeException("End value shoult be bigger then start, but it's not.");
throw new RuntimeException("End value should be bigger than start, but it's not.");

this.start = start;
this.end = end;
Expand All @@ -22,13 +22,23 @@ static double[] getDataAndResultPair(double x) {
return new double[]{x, function(x)};
}


static double function(double x) {
return tan(2 * x) - 3;
}

public double[][] getTable() {
int rows = (int) ((end-start)/step) + 1;
int columns = 2;
double[][] table = new double[rows][columns];
for (int row = 0; row<rows; row++){
double x = start + row*step;
table[row][0] = x;
table [row][1] = function(x);
}


//todo реализовать
return new double[0][0];
return table;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.epam.courses.java.fundamentals.intro.practice.task3;

import static java.lang.System.out;

import java.io.PrintStream;

import static java.lang.System.out;

public class TablePrinter {

private final Table table;
Expand All @@ -27,12 +27,22 @@ private void printTable(int quantity, PrintStream out) {
}

private void printBottom(int quantity, PrintStream out) {
out.print("+-------------------------+");
String strip = strip(quantity + 1);
out.printf("+%s-%s+\n", strip, strip);
}

private String strip(int quantity) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < quantity; i++)
sb.append("-");

return sb.toString();
}

private void printTop(int quantity, PrintStream out) {
out.println("+-------------------------+"); // TODO: Сделать ширину каждого заголовка равной quantity
String strip = strip(quantity + 1);
out.printf("+%s-%s+\n", strip, strip); // TODO: Сделать ширину каждого заголовка равной quantity
out.println("| x | f(x) |");
out.println("+-------------------------+");
out.printf("+%s-%s+\n", strip, strip);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ public MaxFinder(double... as) {
}

public double getMaximum() {
//todo реализовать!
return 0;
double maximum = Double.NEGATIVE_INFINITY;
for (int i = 0; i<as.length-1; i++){
double first = as[i];
double second = as[i+1];
double sum = first + second;
maximum = Math.max(maximum, sum);
}
return maximum;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public CrossMatrix(int size) {
}

public boolean get(int x, int y) {
//todo: реализовать!
return false;
return x+y == size - 1 || x == y;

}

@Override
Expand Down
5 changes: 3 additions & 2 deletions intro/start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
mkdir -p target/classes
#javac ...
#java ...
javac src/main/java/com/epam/courses/java/fundamentals/intro/practice/task1/*.java -d target/classes/
java -cp target/classes/ com.epam.courses.java.fundamentals.intro.practice.task1.Main