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
Binary file added MyInterface.class
Binary file not shown.
3 changes: 3 additions & 0 deletions MyInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public interface MyInterface {
public double compute(double a, double b, double c, int iteration);
}
Binary file added Quadratic.class
Binary file not shown.
13 changes: 13 additions & 0 deletions Quadratic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Quadratic implements MyInterface {
public double compute(double a, double b, double c, int iteration) {
double answer = 0;
if (iteration == 1) {
answer = (-b + Math.sqrt(Math.pow(b, 2) - 4*a*c)) / (2*a);
}
if (iteration == 2) {
answer = (-b - Math.sqrt(Math.pow(b, 2) - 4*a*c)) / (2*a);
}
return answer;
}

}
Binary file added mainCompute.class
Binary file not shown.
20 changes: 20 additions & 0 deletions mainCompute.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.util.Scanner;

public class mainCompute{

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);

MyInterface getQuadratic = new Quadratic();

System.out.println("Ruutvõrrandi arvutaja\n\nPalun sisestage ruutvõrrandi jaoks vajalikud andmed");
System.out.println("A (ruudus): ");
double a = scan.nextDouble();
System.out.println("B: ");
double b = scan.nextDouble();
System.out.println("C: ");
double c = scan.nextDouble();
System.out.println("\nVastus 1: " + getQuadratic.compute(a, b, c, 1));
System.out.println("Vastus 2: " + getQuadratic.compute(a, b, c, 2));
}
}