package com.company;
import java.util.Scanner;
class Variable {
private double a;
private double b;
private double c;
void input()
{
Scanner scan
= new Scanner
(System.
in);
a
= Dialog.
isEnteringValues(scan,
"A");
b
= Dialog.
isEnteringValues(scan,
"B");
c
= Dialog.
isEnteringValues(scan,
"C");
}
void view()
{
Dialog.
isEnteredValues(a, b, c
);
}
void calculate()
{
double delta = b * b - 4 * a * c;
if (delta < 0)
else {
if (delta == 0) {
double x0 = -b / (2 * a);
}
if (delta > 0) {
double x1
= (-b
- Math.
sqrt(delta
)) / 2 * a
;
double x2
= (-b
+ Math.
sqrt(delta
)) / 2 * a
;
}
}
}
}
static double isEnteringValues
(Scanner scan,
String str
)
{
System.
out.
print("Wprowadź wartość liczby " + str
+ ": ");
return scan.nextDouble();
}
static void isEnteredValues(double a, double b, double c)
{
System.
out.
println("A: " + a
);
System.
out.
println("B: " + b
);
System.
out.
println("C: " + c
);
}
static void isDeltaResult(double delta)
{
System.
out.
println("D: " + delta
);
}
static void isNoSolution()
{
System.
out.
println("Brak rozwiązania.");
}
static void isOneSolution(double x0)
{
System.
out.
println("x0: " + x0
);
}
static void isTwoSolution(double x1, double x2)
{
System.
out.
println("x1: " + x1
);
System.
out.
println("x2: " + x2
);
}
}
public class Calculation {
public static void main
(String[] args
) {
Variable variable = new Variable();
variable.input();
variable.view();
variable.calculate();
}
}
Replies to LAB02_ZAD02
Title |
Name |
Language |
UNIX |
When |
Re: LAB02_ZAD02 |
Chartreuse Elephant |
java |
1540453884 |
5 Years ago. |
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}