首页 > 代码库 > 二元一次方程
二元一次方程
package pers.weineel.quadratic;
import java.util.Random;
/**
* Created by weineeL on 2016/10/9.
*/
public class Quadratic {
private int a;
private int b;
private int c;
private Random rd = new Random();
public int getA() {
int temp = rd.nextInt(100);
a = temp == 0 ? temp + 1 : temp;
return a;
}
public int getB() {
b = rd.nextInt(100);
return b;
}
public int getC() {
c = rd.nextInt(100);
return c;
}
public String getQuadratic(){
int B = getB();
int C = getC();
return getA() + "x^2 + " + (B == 0 ? "" : B + "x + ") + (C == 0 ? "" : C) + " = 0";
}
public static void main(String [] argv){
Quadratic quadratic = new Quadratic();
System.out.println(quadratic.getQuadratic());
}
}
二元一次方程