tarde ,lo que se pide es que resuelva sistemas de ecuaciones lineales
y que las soluciones puedan ser una negativa o dos positvas o dos negativas
http://www.vadenumeros.es/tercero/sistemas-de-ecuaciones.htm
Y claro está tienen dos incógnitas x e y,que llegan hasta 19 , aunque se pued kmbiar
Y aquí va la solución
Código:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class ekuations {
public static void main(String[] args)throws IOException{
int u;
int d;
int t;
int u1;
int d1;
int t1;
System.out.println("===============Nukemsolver v0.1==================");
System.out.println("===============Licencia creative commons=========");
System.out.println("===============created por valium7===============");
System.out.println("Introduzca var x");
u =Integer.parseInt( new BufferedReader(new InputStreamReader(System.in)).readLine());
System.out.println("Introduzca var y");
d =Integer.parseInt( new BufferedReader(new InputStreamReader(System.in)).readLine());
System.out.println("Introduzca var result");
t =Integer.parseInt( new BufferedReader(new InputStreamReader(System.in)).readLine());
System.out.println("Ecuation introducida "+ u+"x" + " " +d+"y"+"="+t+ " Introduzca ahora la 2da ");
System.out.println("Introduzca var x");
u1 =Integer.parseInt( new BufferedReader(new InputStreamReader(System.in)).readLine());
System.out.println("Introduzca var y");
d1 =Integer.parseInt( new BufferedReader(new InputStreamReader(System.in)).readLine());
System.out.println("Introduzca var result");
t1 =Integer.parseInt( new BufferedReader(new InputStreamReader(System.in)).readLine());
System.out.println("Ecuation introducida "+ u1+"x" + " " +d1+"y"+"="+t1 );
for (double i =1;i<21;i++){ //COMPROBACIÓN
i-=1;
i =aniadir(i);
for (double i1=0;i1<21;i1++){
double fatemp[];
i1-=1;
// System.out.println("USados "+i+" "+i1);
i1 =aniadir(i1);
fatemp =math(u,d,i,i1);
if (fatemp[0]+fatemp[1]==t){
if(verificar(i,i1,u1,d1,t1)){
System.out.println("¡Bingo!,¡Bango!,¡Bongo! , x igual a "+i+ " e y igual a "+i1);
break;}
}
}
}
for (double i =1;i<20;i++){ //SEGUNDA COMPROBACIÓN
i-=1;
i=aniadir(i);
for (double i1=0;i1>-20;i1--){
double fatemp[];
i1+=1;
// System.out.println("USados "+i+" "+i1);
i1 =aniadirminus(i1);
fatemp =math(u,d,i,i1);
if (fatemp[0]+fatemp[1]==t){
if(verificar(i,i1,u1,d1,t1)){
System.out.println("1¡Bingo!,¡Bango!,¡Bongo! , x igual a "+i+ " e y igual a "+i1);
break;}
}
}
}
for (double i =1;i>-20;i--){ // TERCERA COMPROBACIÓN
i+=1;
i=aniadirminus(i);
for (double i1=0;i1<20;i1++){
double fatemp[];
i1-=1;
// System.out.println("USados "+i+" "+i1);
i1 =aniadir(i1);
fatemp =math(u,d,i,i1);
if (fatemp[0]+fatemp[1]==t){
if(verificar(i,i1,u1,d1,t1)){
System.out.println("2¡Bingo!,¡Bango!,¡Bongo! , x igual a "+i+ " e y igual a "+i1);
break;}
}
}
}
for (double i =1;i>-20;i--){//CUARTA COMPROBACIÓN
i+=1;
i=aniadirminus(i);
for (double i1=0;i1>-20;i1--){
double fatemp[];
i1+=1;
// System.out.println("USados "+i+" "+i1);
i1 =aniadirminus(i1);
fatemp =math(u,d,i,i1);
if (fatemp[0]+fatemp[1]==t){
if(verificar(i,i1,u1,d1,t1)){
System.out.println("T¡Bingo!,¡Bango!,¡Bongo! , x igual a "+i+ " e y igual a "+i1);
break;}
}
}
}
}
public static double aniadir(double a){ //Añadimos mitad a positivos
double mitad= 0.5;
double b = a + mitad;
// System.out.println("float obtenido "+b);
return b;
}
public static double aniadirminus(double a){//Añadimos mitad a negativs
double mitad= -0.5;
double b = a + mitad;
// System.out.println("float obtenido "+b);
return b;
}
public static double[] math(double a , double b ,double operar,double operar1){
double result = 0;
double result1 = 0;
result= a*operar;
result1= b*operar1;
double[] resultotal={result,result1};
return resultotal;
}
public static boolean verificar(double x,double y,int xotra, int yotra,int resultotra){
boolean tilt =false;
if(xotra*x+(yotra*y)==resultotra){tilt=true;}
return tilt;
}
}