NoNameCracksInc icon

Java equations counter.

NoNameCracksInc | PRO | 07/31/13 12:38:54 PM UTC | 0 ⭐ | 328 👁️ | Never ⏰ | []
Java |

1.93 KB

|

None

|

0 👍

/

0 👎

Hello.Those who are going to school and have sometimes problems with equations could possibly use my code.This version counts equation with two variables.1.Find equation you can't count.2.Each part of code where is 'a+6+b+8*4' replace with your left side of equation.3.Instead of result 1016 write result of your equation.(It does not have to be number.You can use variables in solution too.).Then you can launch program.It asks you to choose speed of test.If you insert fast, program will test 4 milions combinations of numbers and if you write slow, program will test 16 milions combinations.You can also add your own variables declaring them as static at begining of code.This is something like beta so it requires more manual work.I'm going to improve it but it can help somebody who is bad at equations.
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Buffer{
    static int a;
    static int b;
    static BufferedReader reader;
    static String query;
    static int range;
 
    public static void main(String[] args)throws IOException{
        reader=new BufferedReader(new InputStreamReader(System.in));
        
        System.out.print("Choose speed of test(fast or slow):");
        query=reader.readLine();
        
        if(query.equals("fast"))
            range=2000;
        else
            range=4000;
        
         //START THE TEST//       
        while((a+6+b+8*4)!=1016){
            b=b+1;
            if(b==range+1){
                b=0;
                a=a+1;
            }
            if((a+6+b+8*4)!=1016)
                System.out.println("a- "+a+", "+"b- "+b+"=false.");
            
            if((a+6+b+8*4)==1016){
                System.out.println("a- "+a+", "+"b- "+b+"=true.");
                System.out.println("\n"+"Done.You can possibly solve this equation, if a= "+a+" and b= "+b+".");
            }
            if(a==range&&b==range&&(a+6+b+8*4)!=1016){
                System.out.println("\n"+"Tested "+a*b+" options.Solution not found.");
                System.exit(0);
            }
        }   
    }
}

Comments