Поможем написать учебную работу
Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.
Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.
№9
package rivvnannja;
public class Test
{
float a, b, c;
float d;
int n;
public Test (){
a = 1;
b = 1;
c = 1;}
public Test(float a, float b, float c){
this.a = a;
this.b = b;
this.c = c;}
public String toString(){
return new String("a = "+this.a+ " b = " +this.b + " c = "+this.c+" d = "+this.d);}
public void setD ( ){
this.d = (this.b * this.b) - (4 * this.a * this.c);}
public int countN (){
if (this.d < 0) this.n = 0;
else if (this.d == 0) this.n = 1;
else this.n = 2;
return this.n;}
public float[] getX (){
float arr[];
if (this.d < 0) {
arr = null;}
else if (this.d == 0) {
arr = new float [1];
arr[0] = (-this.b) / (2 * this.a);}
else {
arr = new float [2];
arr[0] = (float) ((-this.b + Math.sqrt(this.d)) / (2 * this.a));
arr[1] = (float) ((-this.b - Math.sqrt(this.d)) / (2 * this.a));}
return arr;}
public static void main(String args []){
Test a = new Test (1,6,2);
a.setD();
a.countN();
float arr[] = a.getX();
System.out.println(a.toString());
if (arr == null ){ System.out.println("koreniv nema"); }
else
for (float i:arr){
System.out.println("x = "+i);
} } }
№9
package rivvnannja;
public class Test
{
float a, b, c;
float d;
int n;
public Test (){
a = 1;
b = 1;
c = 1;}
public Test(float a, float b, float c){
this.a = a;
this.b = b;
this.c = c;}
public String toString(){
return new String("a = "+this.a+ " b = " +this.b + " c = "+this.c+" d = "+this.d);}
public void setD ( ){
this.d = (this.b * this.b) - (4 * this.a * this.c);}
public int countN (){
if (this.d < 0) this.n = 0;
else if (this.d == 0) this.n = 1;
else this.n = 2;
return this.n;}
public float[] getX (){
float arr[];
if (this.d < 0) {
arr = null;}
else if (this.d == 0) {
arr = new float [1];
arr[0] = (-this.b) / (2 * this.a);}
else {
arr = new float [2];
arr[0] = (float) ((-this.b + Math.sqrt(this.d)) / (2 * this.a));
arr[1] = (float) ((-this.b - Math.sqrt(this.d)) / (2 * this.a));}
return arr;}
public static void main(String args []){
Test a = new Test (1,6,2);
a.setD();
a.countN();
float arr[] = a.getX();
System.out.println(a.toString());
if (arr == null ){ System.out.println("koreniv nema"); }
else
for (float i:arr){
System.out.println("x = "+i);
} } }
№9
package rivvnannja;
public class Test
{
float a, b, c;
float d;
int n;
public Test (){
a = 1;
b = 1;
c = 1;}
public Test(float a, float b, float c){
this.a = a;
this.b = b;
this.c = c;}
public String toString(){
return new String("a = "+this.a+ " b = " +this.b + " c = "+this.c+" d = "+this.d);}
public void setD ( ){
this.d = (this.b * this.b) - (4 * this.a * this.c);}
public int countN (){
if (this.d < 0) this.n = 0;
else if (this.d == 0) this.n = 1;
else this.n = 2;
return this.n;}
public float[] getX (){
float arr[];
if (this.d < 0) {
arr = null;}
else if (this.d == 0) {
arr = new float [1];
arr[0] = (-this.b) / (2 * this.a);}
else {
arr = new float [2];
arr[0] = (float) ((-this.b + Math.sqrt(this.d)) / (2 * this.a));
arr[1] = (float) ((-this.b - Math.sqrt(this.d)) / (2 * this.a));}
return arr;}
public static void main(String args []){
Test a = new Test (1,6,2);
a.setD();
a.countN();
float arr[] = a.getX();
System.out.println(a.toString());
if (arr == null ){ System.out.println("koreniv nema"); }
else
for (float i:arr){
System.out.println("x = "+i);
} } }
№9
package rivvnannja;
public class Test
{
float a, b, c;
float d;
int n;
public Test (){
a = 1;
b = 1;
c = 1;}
public Test(float a, float b, float c){
this.a = a;
this.b = b;
this.c = c;}
public String toString(){
return new String("a = "+this.a+ " b = " +this.b + " c = "+this.c+" d = "+this.d);}
public void setD ( ){
this.d = (this.b * this.b) - (4 * this.a * this.c);}
public int countN (){
if (this.d < 0) this.n = 0;
else if (this.d == 0) this.n = 1;
else this.n = 2;
return this.n;}
public float[] getX (){
float arr[];
if (this.d < 0) {
arr = null;}
else if (this.d == 0) {
arr = new float [1];
arr[0] = (-this.b) / (2 * this.a);}
else {
arr = new float [2];
arr[0] = (float) ((-this.b + Math.sqrt(this.d)) / (2 * this.a));
arr[1] = (float) ((-this.b - Math.sqrt(this.d)) / (2 * this.a));}
return arr;}
public static void main(String args []){
Test a = new Test (1,6,2);
a.setD();
a.countN();
float arr[] = a.getX();
System.out.println(a.toString());
if (arr == null ){ System.out.println("koreniv nema"); }
else
for (float i:arr){
System.out.println("x = "+i);
} } }
№9
package rivvnannja;
public class Test
{
float a, b, c;
float d;
int n;
public Test (){
a = 1;
b = 1;
c = 1;}
public Test(float a, float b, float c){
this.a = a;
this.b = b;
this.c = c;}
public String toString(){
return new String("a = "+this.a+ " b = " +this.b + " c = "+this.c+" d = "+this.d);}
public void setD ( ){
this.d = (this.b * this.b) - (4 * this.a * this.c);}
public int countN (){
if (this.d < 0) this.n = 0;
else if (this.d == 0) this.n = 1;
else this.n = 2;
return this.n;}
public float[] getX (){
float arr[];
if (this.d < 0) {
arr = null;}
else if (this.d == 0) {
arr = new float [1];
arr[0] = (-this.b) / (2 * this.a);}
else {
arr = new float [2];
arr[0] = (float) ((-this.b + Math.sqrt(this.d)) / (2 * this.a));
arr[1] = (float) ((-this.b - Math.sqrt(this.d)) / (2 * this.a));}
return arr;}
public static void main(String args []){
Test a = new Test (1,6,2);
a.setD();
a.countN();
float arr[] = a.getX();
System.out.println(a.toString());
if (arr == null ){ System.out.println("koreniv nema"); }
else
for (float i:arr){
System.out.println("x = "+i);
} } }