/** ***************************************************************** check24Online.java Servlet version of check24. @author Jeff Offutt @version 1.0 (5/2/2005) ********************************************************************* */ // Import Servlet Libraries import javax.servlet.*; import javax.servlet.http.*; // Import Java Libraries import java.io.*; import java.util.StringTokenizer; public class check24Online extends HttpServlet { /** ***************************************************** * Replaces main() in the command-line version * Gets the four values from the form and calls * the method checkSolutions() to get all solutions. ********************************************************* */ public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { int Ain=1, Bin=1, Cin=1, Din=1; res.setContentType ("TEXT/HTML"); PrintWriter out = res.getWriter (); PrintHead (out); String val1AsStr = req.getParameter ("value1"); String val2AsStr = req.getParameter ("value2"); String val3AsStr = req.getParameter ("value3"); String val4AsStr = req.getParameter ("value4"); try { Ain = Integer.parseInt (val1AsStr); Bin = Integer.parseInt (val2AsStr); Cin = Integer.parseInt (val3AsStr); Din = Integer.parseInt (val4AsStr); } catch (NumberFormatException e) { // nonnumeric, ask the user to try again. out.println ("
"); out.println ("One or more of your entries was not numeric."); out.println ("Please use only integers, no characters or spaces."); out.println ("
"); out.println ("Return to game."); out.println (""); out.println (""); out.close (); return; } out.println ("Searching for solutions ..."); out.println ("
"); out.println ("
"); out.println ("
"); // Try with all combinations. checkSolutions (Ain, Bin, Cin, Din, out); checkSolutions (Ain, Bin, Din, Cin, out); checkSolutions (Ain, Cin, Bin, Din, out); checkSolutions (Ain, Cin, Din, Bin, out); checkSolutions (Ain, Din, Bin, Cin, out); checkSolutions (Ain, Din, Cin, Bin, out); checkSolutions (Bin, Ain, Cin, Din, out); checkSolutions (Bin, Ain, Din, Cin, out); checkSolutions (Bin, Cin, Ain, Din, out); checkSolutions (Bin, Cin, Din, Ain, out); checkSolutions (Bin, Din, Ain, Cin, out); checkSolutions (Bin, Din, Cin, Ain, out); checkSolutions (Cin, Ain, Bin, Din, out); checkSolutions (Cin, Ain, Din, Bin, out); checkSolutions (Cin, Bin, Ain, Din, out); checkSolutions (Cin, Bin, Din, Ain, out); checkSolutions (Cin, Din, Ain, Bin, out); checkSolutions (Cin, Din, Bin, Ain, out); checkSolutions (Din, Ain, Cin, Bin, out); checkSolutions (Din, Ain, Bin, Cin, out); checkSolutions (Din, Cin, Ain, Bin, out); checkSolutions (Din, Cin, Bin, Ain, out); checkSolutions (Din, Bin, Ain, Cin, out); checkSolutions (Din, Bin, Cin, Ain, out); out.println ("
"); out.println ("Try another ...
"); PrintForm (out); out.println (""); out.println (""); out.close (); } /** ***************************************************** * Overrides HttpServlet's doGet(). * Reprints the HTML page, blank. ********************************************************* */ public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // Prints the form, added for completeness. res.setContentType ("TEXT/HTML"); PrintWriter out = res.getWriter (); PrintHead (out); PrintForm (out); PrintTail (out); } /** ***************************************************** * Prints the head of the HTML response page ********************************************************* */ private void PrintHead (PrintWriter out) throws IOException { out.println (""); out.println (""); out.println (" The Card Game of 24"); out.println (" "); out.println (" "); out.println (""); out.println (" "); out.println (" "); out.println ("

The Card Game of 24

"); out.println ("
"); } /** ***************************************************** * Prints the form of the HTML page. * Also prints out the bottom and closes the PrintWriter. ********************************************************* */ private void PrintForm (PrintWriter out) throws IOException { // Reprints the form, just like the original HTML out.println ("
"); out.println ("

"); out.println ("Please enter four integer values between 1 and 24 inclusive."); out.println ("This program will return all expressions using the four operators"); out.println ("+, -, * and / that use each value exactly once and that have the result 24."); out.println ("There may be a lot of what looks like duplicates,"); out.println ("but they are actually different ways of rearranging the numbers."); out.println ("(This program can actually handle all integers.)"); out.println (""); out.println ("

"); out.println (""); out.println (""); out.println (" "); out.println (" "); out.println (" "); out.println (" "); out.println (" "); out.println (" "); out.println ("
Value 1: Value 2: Value 3: Value 4:
"); out.println (""); out.println (" "); out.println (" "); out.println (" "); out.println (" "); out.println (" "); out.println ("
"); out.println (""); out.println ("

"); out.println (""); } /** ***************************************************** * Prints the tail of the HTML page. * Prints out the bottom and closes the PrintWriter. ********************************************************* */ private void PrintTail (PrintWriter out) throws IOException { out.println ("
"); out.println ("
"); out.println ("
"); out.println ("
"); out.println ("
"); out.println ("
"); out.println ("
"); out.println (""); out.println ("
"); out.println ("

"); out.println ("About 24:"); out.println ("

"); out.println ("

"); out.println ("The basic game of 24 is generations old."); out.println ("It has been played in Asian countries, in particular China,"); out.println ("since at least the mid-20th century."); out.println ("There, it was usually played with regular playing (poker) cards and"); out.println ("using numbers from 1 (aces) through 13 (kings)."); out.println ("Robert Sun created a variant of the game that"); out.println ("used specialized cards with four numbers per card,"); out.println ("each of which is guaranteed to have a solution."); out.println ("He also created other variations and markets it in the USA"); out.println ("with his company Suntex"); out.println ("(http://www.24game.com/)"); out.println ("as a teaching tool and for competition among elementary school students."); out.println ("Their website begins the description of the game as follows:"); out.println (""); out.println (""); out.println (""); out.println ("

"); out.println ("Mathematically, the game comes out of number theory,"); out.println ("specifically the theory of \"abundant numbers\"."); out.println ("An abundant number is one for which the sum of its divisors are greater"); out.println ("than the number itself."); out.println ("So, &Sigma divisors(24) = 2+3+4+6+8+12 = 35."); out.println ("This makes 24 a great candidate for this game"); out.println ("(although 12, 36, and 48 might be reasonable alternatives)."); out.println ("More details on abundant numbers can be found on"); out.println ("mathworld."); out.println ("


"); out.println (""); out.println ("

"); out.println (""); out.println ("© Jeff Offutt, 2005, all rights reserved."); out.println (" Copying, distribution or other use of this program"); out.println (" without express permission of the author is forbidden."); out.println (" You may create links to pages in this web site,"); out.println (" but may not copy all or part of the text without permission"); out.println (" of the author."); out.println (""); out.println (""); out.println (""); out.println (""); out.close (); } // ********************************************** // 936 combinations - strictly brute force. // All operators in all orders, with all parenthizations // Uses exception block around all divides // Checks for roundoff errors by comparing with a float value // (that is, 23.8 is not really a solution) // // I can't guarantee all cases are correct - think about // trying to branch test this program!! // ********************************************** private static void checkSolutions (int a, int b, int c, int d, PrintWriter out) { int rslt; /**** + + + ***/ rslt = a+b+c+d; if (rslt == 24 && rslt == (float)a+(float)b+(float)c+(float)d) out.println ("Solution found: "+a+"+"+b+"+"+c+"+"+d+" = 24
"); /**** + + ? ***/ rslt = a+b+c-d; if (rslt == 24 && rslt == (float)a+(float)b+(float)c-(float)d) out.println ("Solution found: "+a+"+"+b+"+"+c+"-"+d+" = 24
"); rslt = a+b+c*d; if (rslt == 24 && rslt == (float)a+(float)b+(float)c*(float)d) out.println ("Solution found: "+a+"+"+b+"+"+c+"*"+d+" = 24
"); rslt = (a+b+c)*d; if (rslt == 24 && rslt == ((float)a+(float)b+(float)c)*(float)d) out.println ("Solution found: ("+a+"+"+b+"+"+c+")*"+d+" = 24
"); try { rslt = a+b+c/d; if (rslt == 24 && rslt == (float)a+(float)b+(float)c/(float)d) out.println ("Solution found: "+a+"+"+b+"+"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b+c)/d; if (rslt == 24 && rslt == ((float)a+(float)b+(float)c)/(float)d) out.println ("Solution found: ("+a+"+"+b+"+"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** + - ? ***/ rslt = a+b-c+d; if (rslt == 24 && rslt == (float)a+(float)b-(float)c+(float)d) out.println ("Solution found: "+a+"+"+b+"-"+c+"+"+d+" = 24
"); rslt = a+b-c-d; if (rslt == 24 && rslt == (float)a+(float)b-(float)c-(float)d) out.println ("Solution found: "+a+"+"+b+"-"+c+"-"+d+" = 24
"); rslt = a+b-c*d; if (rslt == 24 && rslt == (float)a+(float)b-(float)c*(float)d) out.println ("Solution found: "+a+"+"+b+"-"+c+"*"+d+" = 24
"); rslt = (a+b-c)*d; if (rslt == 24 && rslt == ((float)a+(float)b-(float)c)*(float)d) out.println ("Solution found: ("+a+"+"+b+"-"+c+")*"+d+" = 24
"); try { rslt = a+b-c/d; if (rslt == 24 && rslt == (float)a+(float)b-(float)c/(float)d) out.println ("Solution found: "+a+"+"+b+"-"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b-c)/d; if (rslt == 24 && rslt == ((float)a+(float)b-(float)c)/(float)d) out.println ("Solution found: ("+a+"+"+b+"-"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** + * ? ***/ rslt = a+b*c+d; if (rslt == 24 && rslt == (float)a+(float)b*(float)c+(float)d) out.println ("Solution found: "+a+"+"+b+"*"+c+"+"+d+" = 24
"); rslt = (a+b)*(c+d); if (rslt == 24 && rslt == ((float)a+(float)b)*((float)c+(float)d)) out.println ("Solution found: ("+a+"+"+b+")*("+c+"+"+d+") = 24
"); rslt = a+b*c-d; if (rslt == 24 && rslt == (float)a+(float)b*(float)c-(float)d) out.println ("Solution found: "+a+"+"+b+"*"+c+"-"+d+" = 24
"); rslt = (a+b)*(c-d); if (rslt == 24 && rslt == ((float)a+(float)b)*((float)c-(float)d)) out.println ("Solution found: ("+a+"+"+b+")*("+c+"-"+d+") = 24
"); rslt = a+b*c*d; if (rslt == 24 && rslt == (float)a+(float)b*(float)c*(float)d) out.println ("Solution found: "+a+"+"+b+"*"+c+"*"+d+" = 24
"); rslt = (a+b)*c*d; if (rslt == 24 && rslt == ((float)a+(float)b)*(float)c*(float)d) out.println ("Solution found: ("+a+"+"+b+")*"+c+"*"+d+" = 24
"); try { rslt = a+b*c/d; if (rslt == 24 && rslt == (float)a+(float)b*(float)c/(float)d) out.println ("Solution found: "+a+"+"+b+"*"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)*c/d; if (rslt == 24 && rslt == ((float)a+(float)b)*(float)c/(float)d) out.println ("Solution found: ("+a+"+"+b+")*"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a+b*(c/d); if (rslt == 24 && rslt == (float)a+(float)b*((float)c/(float)d)) out.println ("Solution found: "+a+"+"+b+"*("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)*(c/d); if (rslt == 24 && rslt == ((float)a+(float)b)*((float)c/(float)d)) out.println ("Solution found: ("+a+"+"+b+")*("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } /**** + / ? ***/ try { rslt = a+b/c+d; if (rslt == 24 && rslt == (float)a+(float)b/(float)c+(float)d) out.println ("Solution found: "+a+"+"+b+"/"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)/(c+d); if (rslt == 24 && rslt == ((float)a+(float)b)/((float)c+(float)d)) out.println ("Solution found: ("+a+"+"+b+")/("+c+"+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)/c+d; if (rslt == 24 && rslt == ((float)a+(float)b)/(float)c+(float)d) out.println ("Solution found: ("+a+"+"+b+")/"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a+b/(c+d); if (rslt == 24 && rslt == (float)a+(float)b/((float)c+(float)d)) out.println ("Solution found: "+a+"+"+b+"/("+c+"+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a+b/c-d; if (rslt == 24 && rslt == (float)a+(float)b/(float)c-(float)d) out.println ("Solution found: "+a+"+"+b+"/"+c+"-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)/(c-d); if (rslt == 24 && rslt == ((float)a+(float)b)/((float)c-(float)d)) out.println ("Solution found: ("+a+"+"+b+")/("+c+"-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)/(c-d); if (rslt == 24 && rslt == ((float)a+(float)b)/((float)c-(float)d)) out.println ("Solution found: ("+a+"+"+b+")/("+c+"-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)/c-d; if (rslt == 24 && rslt == ((float)a+(float)b)/(float)c-(float)d) out.println ("Solution found: ("+a+"+"+b+")/"+c+"-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a+b/(c-d); if (rslt == 24 && rslt == (float)a+(float)b/((float)c-(float)d)) out.println ("Solution found: "+a+"+"+b+"/("+c+"-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a+b/c*d; if (rslt == 24 && rslt == (float)a+(float)b/(float)c*(float)d) out.println ("Solution found: "+a+"+"+b+"/"+c+"*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)/(c*d); if (rslt == 24 && rslt == ((float)a+(float)b)/((float)c*(float)d)) out.println ("Solution found: ("+a+"+"+b+")/("+c+"*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)/c*d; if (rslt == 24 && rslt == ((float)a+(float)b)/(float)c*(float)d) out.println ("Solution found: ("+a+"+"+b+")/"+c+"*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a+b/(c*d); if (rslt == 24 && rslt == (float)a+(float)b/((float)c*(float)d)) out.println ("Solution found: "+a+"+"+b+"/("+c+"*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a+b/c/d; if (rslt == 24 && rslt == (float)a+(float)b/(float)c/(float)d) out.println ("Solution found: "+a+"+"+b+"/"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)/(c/d); if (rslt == 24 && rslt == ((float)a+(float)b)/((float)c/(float)d)) out.println ("Solution found: ("+a+"+"+b+")/("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a+b)/c/d; if (rslt == 24 && rslt == ((float)a+(float)b)/(float)c/(float)d) out.println ("Solution found: ("+a+"+"+b+")/"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a+b/(c/d); if (rslt == 24 && rslt == (float)a+(float)b/((float)c/(float)d)) out.println ("Solution found: "+a+"+"+b+"/("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } /**** - + + ***/ rslt = a-b+c+d; if (rslt == 24 && rslt == (float)a-(float)b+(float)c+(float)d) out.println ("Solution found: "+a+"-"+b+"+"+c+"+"+d+" = 24
"); rslt = a-(b+c+d); if (rslt == 24 && rslt == (float)a-((float)b+(float)c+(float)d)) out.println ("Solution found: "+a+"-("+b+"+"+c+"+"+d+") = 24
"); /**** - + ? ***/ rslt = a-b+c-d; if (rslt == 24 && rslt == (float)a-(float)b+(float)c-(float)d) out.println ("Solution found: "+a+"-"+b+"+"+c+"-"+d+" = 24
"); rslt = a-(b+c)-d; if (rslt == 24 && rslt == (float)a-((float)b+(float)c)-(float)d) out.println ("Solution found: "+a+"-("+b+"+"+c+")-"+d+" = 24
"); rslt = a-((b+c)-d); if (rslt == 24 && rslt == (float)a-(((float)b+(float)c)-(float)d)) out.println ("Solution found: "+a+"-(("+b+"+"+c+")-"+d+") = 24
"); rslt = a-b+c*d; if (rslt == 24 && rslt == (float)a-(float)b+(float)c*(float)d) out.println ("Solution found: "+a+"-"+b+"+"+c+"*"+d+" = 24
"); rslt = (a-b+c)*d; if (rslt == 24 && rslt == ((float)a-(float)b+(float)c)*(float)d) out.println ("Solution found: ("+a+"-"+b+"+"+c+")*"+d+" = 24
"); rslt = (a-(b+c))*d; if (rslt == 24 && rslt == ((float)a-((float)b+(float)c))*(float)d) out.println ("Solution found: ("+a+"-("+b+"+"+c+"))*"+d+" = 24
"); try { rslt = a-b+c/d; if (rslt == 24 && rslt == (float)a-(float)b+(float)c/(float)d) out.println ("Solution found: "+a+"-"+b+"+"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-b+c)/d; if (rslt == 24 && rslt == ((float)a-(float)b+(float)c)/(float)d) out.println ("Solution found: ("+a+"-"+b+"+"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-(b+c))/d; if (rslt == 24 && rslt == ((float)a-((float)b+(float)c))/(float)d) out.println ("Solution found: ("+a+"-("+b+"+"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** - - ? ***/ rslt = a-b-c+d; if (rslt == 24 && rslt == (float)a-(float)b-(float)c+(float)d) out.println ("Solution found: "+a+"-"+b+"-"+c+"+"+d+" = 24
"); rslt = a-(b-c)+d; if (rslt == 24 && rslt == (float)a-((float)b-(float)c)+(float)d) out.println ("Solution found: "+a+"-("+b+"-"+c+")+"+d+" = 24
"); rslt = a-b-(c+d); if (rslt == 24 && rslt == (float)a-(float)b-((float)c+(float)d)) out.println ("Solution found: "+a+"-"+b+"-("+c+"+"+d+") = 24
"); rslt = a-(b-(c+d)); if (rslt == 24 && rslt == (float)a-((float)b-((float)c+(float)d))) out.println ("Solution found: "+a+"-("+b+"-("+c+"+"+d+")) = 24
"); rslt = a-((b-c)+d); if (rslt == 24 && rslt == (float)a-(((float)b-(float)c)+(float)d)) out.println ("Solution found: "+a+"-(("+b+"-"+c+")+"+d+") = 24
"); rslt = a-b-c-d; if (rslt == 24 && rslt == (float)a-(float)b-(float)c-(float)d) out.println ("Solution found: "+a+"-"+b+"-"+c+"-"+d+" = 24
"); rslt = a-(b-c)-d; if (rslt == 24 && rslt == (float)a-((float)b-(float)c)-(float)d) out.println ("Solution found: "+a+"-("+b+"-"+c+")-"+d+" = 24
"); rslt = a-b-(c-d); if (rslt == 24 && rslt == (float)a-(float)b-((float)c-(float)d)) out.println ("Solution found: "+a+"-"+b+"-("+c+"-"+d+") = 24
"); rslt = a-(b-(c-d)); if (rslt == 24 && rslt == (float)a-((float)b-((float)c-(float)d))) out.println ("Solution found: "+a+"-("+b+"-("+c+"-"+d+")) = 24
"); rslt = a-((b-c)-d); if (rslt == 24 && rslt == (float)a-(((float)b-(float)c)-(float)d)) out.println ("Solution found: "+a+"-(("+b+"-"+c+")-"+d+") = 24
"); rslt = a-b-c*d; if (rslt == 24 && rslt == (float)a-(float)b-(float)c*(float)d) out.println ("Solution found: "+a+"-"+b+"-"+c+"*"+d+" = 24
"); rslt = a-(b-c)*d; if (rslt == 24 && rslt == (float)a-((float)b-(float)c)*(float)d) out.println ("Solution found: "+a+"-("+b+"-"+c+")*"+d+" = 24
"); rslt = a-b-(c*d); if (rslt == 24 && rslt == (float)a-(float)b-((float)c*(float)d)) out.println ("Solution found: "+a+"-"+b+"-("+c+"*"+d+") = 24
"); rslt = a-(b-(c*d)); if (rslt == 24 && rslt == (float)a-((float)b-((float)c*(float)d))) out.println ("Solution found: "+a+"-("+b+"-("+c+"*"+d+")) = 24
"); rslt = a-((b-c)*d); if (rslt == 24 && rslt == (float)a-(((float)b-(float)c)*(float)d)) out.println ("Solution found: "+a+"-(("+b+"-"+c+")*"+d+") = 24
"); rslt = (a-b-c)*d; if (rslt == 24 && rslt == ((float)a-(float)b-(float)c)*(float)d) out.println ("Solution found: ("+a+"-"+b+"-"+c+")*"+d+" = 24
"); rslt = (a-(b-c))*d; if (rslt == 24 && rslt == ((float)a-((float)b-(float)c))*(float)d) out.println ("Solution found: ("+a+"-("+b+"-"+c+"))*"+d+" = 24
"); try { rslt = a-b-c/d; if (rslt == 24 && rslt == (float)a-(float)b-(float)c/(float)d) out.println ("Solution found: "+a+"-"+b+"-"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b-c)/d; if (rslt == 24 && rslt == (float)a-((float)b-(float)c)/(float)d) out.println ("Solution found: "+a+"-("+b+"-"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-b-(c/d); if (rslt == 24 && rslt == (float)a-(float)b-((float)c/(float)d)) out.println ("Solution found: "+a+"-"+b+"-("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b-(c/d)); if (rslt == 24 && rslt == (float)a-((float)b-((float)c/(float)d))) out.println ("Solution found: "+a+"-("+b+"-("+c+"/"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a-((b-c)/d); if (rslt == 24 && rslt == (float)a-(((float)b-(float)c)/(float)d)) out.println ("Solution found: "+a+"-(("+b+"-"+c+")/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-b-c)/d; if (rslt == 24 && rslt == ((float)a-(float)b-(float)c)/(float)d) out.println ("Solution found: ("+a+"-"+b+"-"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-(b-c))/d; if (rslt == 24 && rslt == ((float)a-((float)b-(float)c))/(float)d) out.println ("Solution found: ("+a+"-("+b+"-"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** - * ? ***/ rslt = a-b*c+d; if (rslt == 24 && rslt == (float)a-(float)b*(float)c+(float)d) out.println ("Solution found: "+a+"-"+b+"*"+c+"+"+d+" = 24
"); rslt = a-(b*c)+d; if (rslt == 24 && rslt == (float)a-((float)b*(float)c)+(float)d) out.println ("Solution found: "+a+"-("+b+"*"+c+")+"+d+" = 24
"); rslt = a-b*(c+d); if (rslt == 24 && rslt == (float)a-(float)b*((float)c+(float)d)) out.println ("Solution found: "+a+"-"+b+"*("+c+"+"+d+") = 24
"); rslt = a-(b*(c+d)); if (rslt == 24 && rslt == (float)a-((float)b*((float)c+(float)d))) out.println ("Solution found: "+a+"-("+b+"*("+c+"+"+d+")) = 24
"); rslt = a-((b*c)+d); if (rslt == 24 && rslt == (float)a-(((float)b*(float)c)+(float)d)) out.println ("Solution found: "+a+"-(("+b+"*"+c+")+"+d+") = 24
"); rslt = (a-b*c)+d; if (rslt == 24 && rslt == ((float)a-(float)b*(float)c)+(float)d) out.println ("Solution found: ("+a+"-"+b+"*"+c+")+"+d+" = 24
"); rslt = (a-(b*c))+d; if (rslt == 24 && rslt == ((float)a-((float)b*(float)c))+(float)d) out.println ("Solution found: ("+a+"-("+b+"*"+c+"))+"+d+" = 24
"); rslt = a-b*c-d; if (rslt == 24 && rslt == (float)a-(float)b*(float)c-(float)d) out.println ("Solution found: "+a+"-"+b+"*"+c+"-"+d+" = 24
"); rslt = a-(b*c)-d; if (rslt == 24 && rslt == (float)a-((float)b*(float)c)-(float)d) out.println ("Solution found: "+a+"-("+b+"*"+c+")-"+d+" = 24
"); rslt = a-b*(c-d); if (rslt == 24 && rslt == (float)a-(float)b*((float)c-(float)d)) out.println ("Solution found: "+a+"-"+b+"*("+c+"-"+d+") = 24
"); rslt = a-(b*(c-d)); if (rslt == 24 && rslt == (float)a-((float)b*((float)c-(float)d))) out.println ("Solution found: "+a+"-("+b+"*("+c+"-"+d+")) = 24
"); rslt = a-((b*c)-d); if (rslt == 24 && rslt == (float)a-(((float)b*(float)c)-(float)d)) out.println ("Solution found: "+a+"-(("+b+"*"+c+")-"+d+") = 24
"); rslt = (a-b*c)-d; if (rslt == 24 && rslt == ((float)a-(float)b*(float)c)-(float)d) out.println ("Solution found: ("+a+"-"+b+"*"+c+")-"+d+" = 24
"); rslt = (a-(b*c))-d; if (rslt == 24 && rslt == ((float)a-((float)b*(float)c))-(float)d) out.println ("Solution found: ("+a+"-("+b+"*"+c+"))-"+d+" = 24
"); rslt = a-b*c*d; if (rslt == 24 && rslt == (float)a-(float)b*(float)c*(float)d) out.println ("Solution found: "+a+"-"+b+"*"+c+"*"+d+" = 24
"); rslt = a-(b*c)*d; if (rslt == 24 && rslt == (float)a-((float)b*(float)c)*(float)d) out.println ("Solution found: "+a+"-("+b+"*"+c+")*"+d+" = 24
"); rslt = a-b*(c*d); if (rslt == 24 && rslt == (float)a-(float)b*((float)c*(float)d)) out.println ("Solution found: "+a+"-"+b+"*("+c+"*"+d+") = 24
"); rslt = a-(b*(c*d)); if (rslt == 24 && rslt == (float)a-((float)b*((float)c*(float)d))) out.println ("Solution found: "+a+"-("+b+"*("+c+"*"+d+")) = 24
"); rslt = a-((b*c)*d); if (rslt == 24 && rslt == (float)a-(((float)b*(float)c)*(float)d)) out.println ("Solution found: "+a+"-(("+b+"*"+c+")*"+d+") = 24
"); rslt = (a-b*c)*d; if (rslt == 24 && rslt == ((float)a-(float)b*(float)c)*(float)d) out.println ("Solution found: ("+a+"-"+b+"*"+c+")*"+d+" = 24
"); rslt = (a-(b*c))*d; if (rslt == 24 && rslt == ((float)a-((float)b*(float)c))*(float)d) out.println ("Solution found: ("+a+"-("+b+"*"+c+"))*"+d+" = 24
"); try { rslt = a-b*c/d; if (rslt == 24 && rslt == (float)a-(float)b*(float)c/(float)d) out.println ("Solution found: "+a+"-"+b+"*"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b*c)/d; if (rslt == 24 && rslt == (float)a-((float)b*(float)c)/(float)d) out.println ("Solution found: "+a+"-("+b+"*"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-b*(c/d); if (rslt == 24 && rslt == (float)a-(float)b*((float)c/(float)d)) out.println ("Solution found: "+a+"-"+b+"*("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b*(c/d)); if (rslt == 24 && rslt == (float)a-((float)b*((float)c/(float)d))) out.println ("Solution found: "+a+"-("+b+"*("+c+"/"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a-((b*c)/d); if (rslt == 24 && rslt == (float)a-(((float)b*(float)c)/(float)d)) out.println ("Solution found: "+a+"-(("+b+"*"+c+")/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-b*c)/d; if (rslt == 24 && rslt == ((float)a-(float)b*(float)c)/(float)d) out.println ("Solution found: ("+a+"-"+b+"*"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-(b*c))/d; if (rslt == 24 && rslt == ((float)a-((float)b*(float)c))/(float)d) out.println ("Solution found: ("+a+"-("+b+"*"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** - / ? ***/ try { rslt = a-b/c+d; if (rslt == 24 && rslt == (float)a-(float)b/(float)c+(float)d) out.println ("Solution found: "+a+"-"+b+"/"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b/c)+d; if (rslt == 24 && rslt == (float)a-((float)b/(float)c)+(float)d) out.println ("Solution found: "+a+"-("+b+"/"+c+")+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-b/(c+d); if (rslt == 24 && rslt == (float)a-(float)b/((float)c+(float)d)) out.println ("Solution found: "+a+"-"+b+"/("+c+"+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b/(c+d)); if (rslt == 24 && rslt == (float)a-((float)b/((float)c+(float)d))) out.println ("Solution found: "+a+"-("+b+"/("+c+"+"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a-((b/c)+d); if (rslt == 24 && rslt == (float)a-(((float)b/(float)c)+(float)d)) out.println ("Solution found: "+a+"-(("+b+"/"+c+")+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-b/c)+d; if (rslt == 24 && rslt == ((float)a-(float)b/(float)c)+(float)d) out.println ("Solution found: ("+a+"-"+b+"/"+c+")+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-(b/c))+d; if (rslt == 24 && rslt == ((float)a-((float)b/(float)c))/(float)d) out.println ("Solution found: ("+a+"-("+b+"/"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-b/c-d; if (rslt == 24 && rslt == (float)a-(float)b/(float)c-(float)d) out.println ("Solution found: "+a+"-"+b+"/"+c+"-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b/c)-d; if (rslt == 24 && rslt == (float)a-((float)b/(float)c)-(float)d) out.println ("Solution found: "+a+"-("+b+"/"+c+")-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-b/(c-d); if (rslt == 24 && rslt == (float)a-(float)b/((float)c-(float)d)) out.println ("Solution found: "+a+"-"+b+"/("+c+"-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b/(c-d)); if (rslt == 24 && rslt == (float)a-((float)b/((float)c-(float)d))) out.println ("Solution found: "+a+"-("+b+"/("+c+"-"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a-((b/c)-d); if (rslt == 24 && rslt == (float)a-(((float)b/(float)c)-(float)d)) out.println ("Solution found: "+a+"-(("+b+"/"+c+")-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-b/c)-d; if (rslt == 24 && rslt == ((float)a-(float)b/(float)c)-(float)d) out.println ("Solution found: ("+a+"-"+b+"/"+c+")-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-(b/c))-d; if (rslt == 24 && rslt == ((float)a-((float)b/(float)c))-(float)d) out.println ("Solution found: ("+a+"-("+b+"/"+c+"))-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-b/c*d; if (rslt == 24 && rslt == (float)a-(float)b/(float)c*(float)d) out.println ("Solution found: "+a+"-"+b+"/"+c+"*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b/c)*d; if (rslt == 24 && rslt == (float)a-((float)b/(float)c)*(float)d) out.println ("Solution found: "+a+"-("+b+"/"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-b/(c*d); if (rslt == 24 && rslt == (float)a-(float)b/((float)c*(float)d)) out.println ("Solution found: "+a+"-"+b+"/("+c+"*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b/(c*d)); if (rslt == 24 && rslt == (float)a-((float)b/((float)c*(float)d))) out.println ("Solution found: "+a+"-("+b+"/("+c+"*"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a-((b/c)*d); if (rslt == 24 && rslt == (float)a-(((float)b/(float)c)*(float)d)) out.println ("Solution found: "+a+"-(("+b+"/"+c+")*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-b/c)*d; if (rslt == 24 && rslt == ((float)a-(float)b/(float)c)*(float)d) out.println ("Solution found: ("+a+"-"+b+"/"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-(b/c))*d; if (rslt == 24 && rslt == ((float)a-((float)b/(float)c))*(float)d) out.println ("Solution found: ("+a+"-("+b+"/"+c+"))*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-b/c/d; if (rslt == 24 && rslt == (float)a-(float)b/(float)c/(float)d) out.println ("Solution found: "+a+"-"+b+"/"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b/c)/d; if (rslt == 24 && rslt == (float)a-((float)b/(float)c)/(float)d) out.println ("Solution found: "+a+"-("+b+"/"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a-b/(c/d); if (rslt == 24 && rslt == (float)a-(float)b/((float)c/(float)d)) out.println ("Solution found: "+a+"-"+b+"/("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a-(b/(c/d)); if (rslt == 24 && rslt == (float)a-((float)b/((float)c/(float)d))) out.println ("Solution found: "+a+"-("+b+"/("+c+"/"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a-((b/c)/d); if (rslt == 24 && rslt == (float)a-(((float)b/(float)c)/(float)d)) out.println ("Solution found: "+a+"-(("+b+"/"+c+")/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-b/c)/d; if (rslt == 24 && rslt == ((float)a-(float)b/(float)c)/(float)d) out.println ("Solution found: ("+a+"-"+b+"/"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a-(b/c))/d; if (rslt == 24 && rslt == ((float)a-((float)b/(float)c))/(float)d) out.println ("Solution found: ("+a+"-("+b+"/"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** * + + ***/ rslt = a*b+c+d; if (rslt == 24 && rslt == (float)a*(float)b+(float)c+(float)d) out.println ("Solution found: "+a+"*"+b+"+"+c+"+"+d+" = 24
"); rslt = a*(b+c+d); if (rslt == 24 && rslt == (float)a*((float)b+(float)c+(float)d)) out.println ("Solution found: "+a+"*("+b+"+"+c+"+"+d+") = 24
"); /**** * + ? ***/ rslt = a*b+c-d; if (rslt == 24 && rslt == (float)a*(float)b+(float)c-(float)d) out.println ("Solution found: "+a+"*"+b+"+"+c+"-"+d+" = 24
"); rslt = a*(b+c)-d; if (rslt == 24 && rslt == (float)a*((float)b+(float)c)-(float)d) out.println ("Solution found: "+a+"*("+b+"+"+c+")-"+d+" = 24
"); rslt = a*((b+c)-d); if (rslt == 24 && rslt == (float)a*(((float)b+(float)c)-(float)d)) out.println ("Solution found: "+a+"*(("+b+"+"+c+")-"+d+") = 24
"); rslt = a*b+c*d; if (rslt == 24 && rslt == (float)a*(float)b+(float)c*(float)d) out.println ("Solution found: "+a+"*"+b+"+"+c+"*"+d+" = 24
"); rslt = (a*b+c)*d; if (rslt == 24 && rslt == ((float)a*(float)b+(float)c)*(float)d) out.println ("Solution found: ("+a+"*"+b+"+"+c+")*"+d+" = 24
"); rslt = (a*(b+c))*d; if (rslt == 24 && rslt == ((float)a*((float)b+(float)c))*(float)d) out.println ("Solution found: ("+a+"*("+b+"+"+c+"))*"+d+" = 24
"); try { rslt = a*b+c/d; if (rslt == 24 && rslt == (float)a*(float)b+(float)c/(float)d) out.println ("Solution found: "+a+"*"+b+"+"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*b+c)/d; if (rslt == 24 && rslt == ((float)a*(float)b+(float)c)/(float)d) out.println ("Solution found: ("+a+"*"+b+"+"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*(b+c))/d; if (rslt == 24 && rslt == ((float)a*((float)b+(float)c))/(float)d) out.println ("Solution found: ("+a+"*("+b+"+"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** * - ? ***/ rslt = a*b-c+d; if (rslt == 24 && rslt == (float)a*(float)b-(float)c+(float)d) out.println ("Solution found: "+a+"*"+b+"-"+c+"+"+d+" = 24
"); rslt = a*(b-c)+d; if (rslt == 24 && rslt == (float)a*((float)b-(float)c)+(float)d) out.println ("Solution found: "+a+"*("+b+"-"+c+")+"+d+" = 24
"); rslt = a*b-(c+d); if (rslt == 24 && rslt == (float)a*(float)b-((float)c+(float)d)) out.println ("Solution found: "+a+"*"+b+"-("+c+"+"+d+") = 24
"); rslt = a*(b-(c+d)); if (rslt == 24 && rslt == (float)a*((float)b-((float)c+(float)d))) out.println ("Solution found: "+a+"*("+b+"-("+c+"+"+d+")) = 24
"); rslt = a*((b-c)+d); if (rslt == 24 && rslt == (float)a*(((float)b-(float)c)+(float)d)) out.println ("Solution found: "+a+"*(("+b+"-"+c+")+"+d+") = 24
"); rslt = a*b-c-d; if (rslt == 24 && rslt == (float)a*(float)b-(float)c-(float)d) out.println ("Solution found: "+a+"*"+b+"-"+c+"-"+d+" = 24
"); rslt = a*(b-c)-d; if (rslt == 24 && rslt == (float)a*((float)b-(float)c)-(float)d) out.println ("Solution found: "+a+"*("+b+"-"+c+")-"+d+" = 24
"); rslt = a*b-(c-d); if (rslt == 24 && rslt == (float)a*(float)b-((float)c-(float)d)) out.println ("Solution found: "+a+"*"+b+"-("+c+"-"+d+") = 24
"); rslt = a*(b-(c-d)); if (rslt == 24 && rslt == (float)a*((float)b-((float)c-(float)d))) out.println ("Solution found: "+a+"*("+b+"-("+c+"-"+d+")) = 24
"); rslt = a*((b-c)-d); if (rslt == 24 && rslt == (float)a*(((float)b-(float)c)-(float)d)) out.println ("Solution found: "+a+"*(("+b+"-"+c+")-"+d+") = 24
"); rslt = a*b-c*d; if (rslt == 24 && rslt == (float)a*(float)b-(float)c*(float)d) out.println ("Solution found: "+a+"*"+b+"-"+c+"*"+d+" = 24
"); rslt = a*(b-c)*d; if (rslt == 24 && rslt == (float)a*((float)b-(float)c)*(float)d) out.println ("Solution found: "+a+"*("+b+"-"+c+")*"+d+" = 24
"); rslt = a*b-(c*d); if (rslt == 24 && rslt == (float)a*(float)b-((float)c*(float)d)) out.println ("Solution found: "+a+"*"+b+"-("+c+"*"+d+") = 24
"); rslt = a*(b-(c*d)); if (rslt == 24 && rslt == (float)a*((float)b-((float)c*(float)d))) out.println ("Solution found: "+a+"*("+b+"-("+c+"*"+d+")) = 24
"); rslt = a*((b-c)*d); if (rslt == 24 && rslt == (float)a*(((float)b-(float)c)*(float)d)) out.println ("Solution found: "+a+"*(("+b+"-"+c+")*"+d+") = 24
"); rslt = (a*b-c)*d; if (rslt == 24 && rslt == ((float)a*(float)b-(float)c)*(float)d) out.println ("Solution found: ("+a+"*"+b+"-"+c+")*"+d+" = 24
"); rslt = (a*(b-c))*d; if (rslt == 24 && rslt == ((float)a*((float)b-(float)c))*(float)d) out.println ("Solution found: ("+a+"*("+b+"-"+c+"))*"+d+" = 24
"); try { rslt = a*b-c/d; if (rslt == 24 && rslt == (float)a*(float)b-(float)c/(float)d) out.println ("Solution found: "+a+"*"+b+"-"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b-c)/d; if (rslt == 24 && rslt == (float)a*((float)b-(float)c)/(float)d) out.println ("Solution found: "+a+"*("+b+"-"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*b-(c/d); if (rslt == 24 && rslt == (float)a*(float)b-((float)c/(float)d)) out.println ("Solution found: "+a+"*"+b+"-("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b-(c/d)); if (rslt == 24 && rslt == (float)a*((float)b-((float)c/(float)d))) out.println ("Solution found: "+a+"*("+b+"-("+c+"/"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a*((b-c)/d); if (rslt == 24 && rslt == (float)a*(((float)b-(float)c)/(float)d)) out.println ("Solution found: "+a+"*(("+b+"-"+c+")/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*b-c)/d; if (rslt == 24 && rslt == ((float)a*(float)b-(float)c)/(float)d) out.println ("Solution found: ("+a+"*"+b+"-"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*(b-c))/d; if (rslt == 24 && rslt == ((float)a*((float)b-(float)c))/(float)d) out.println ("Solution found: ("+a+"*("+b+"-"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** * * ? ***/ rslt = a*b*c+d; if (rslt == 24 && rslt == (float)a*(float)b*(float)c+(float)d) out.println ("Solution found: "+a+"*"+b+"*"+c+"+"+d+" = 24
"); rslt = a*(b*c)+d; if (rslt == 24 && rslt == (float)a*((float)b*(float)c)+(float)d) out.println ("Solution found: "+a+"*("+b+"*"+c+")+"+d+" = 24
"); rslt = a*b*(c+d); if (rslt == 24 && rslt == (float)a*(float)b*((float)c+(float)d)) out.println ("Solution found: "+a+"*"+b+"*("+c+"+"+d+") = 24
"); rslt = a*(b*(c+d)); if (rslt == 24 && rslt == (float)a*((float)b*((float)c+(float)d))) out.println ("Solution found: "+a+"*("+b+"*("+c+"+"+d+")) = 24
"); rslt = a*((b*c)+d); if (rslt == 24 && rslt == (float)a*(((float)b*(float)c)+(float)d)) out.println ("Solution found: "+a+"*(("+b+"*"+c+")+"+d+") = 24
"); rslt = (a*b*c)+d; if (rslt == 24 && rslt == ((float)a*(float)b*(float)c)+(float)d) out.println ("Solution found: ("+a+"*"+b+"*"+c+")+"+d+" = 24
"); rslt = (a*(b*c))+d; if (rslt == 24 && rslt == ((float)a*((float)b*(float)c))+(float)d) out.println ("Solution found: ("+a+"*("+b+"*"+c+"))+"+d+" = 24
"); rslt = a*b*c-d; if (rslt == 24 && rslt == (float)a*(float)b*(float)c-(float)d) out.println ("Solution found: "+a+"*"+b+"*"+c+"-"+d+" = 24
"); rslt = a*(b*c)-d; if (rslt == 24 && rslt == (float)a*((float)b*(float)c)-(float)d) out.println ("Solution found: "+a+"*("+b+"*"+c+")-"+d+" = 24
"); rslt = a*b*(c-d); if (rslt == 24 && rslt == (float)a*(float)b*((float)c-(float)d)) out.println ("Solution found: "+a+"*"+b+"*("+c+"-"+d+") = 24
"); rslt = a*(b*(c-d)); if (rslt == 24 && rslt == (float)a*((float)b*((float)c-(float)d))) out.println ("Solution found: "+a+"*("+b+"*("+c+"-"+d+")) = 24
"); rslt = a*((b*c)-d); if (rslt == 24 && rslt == (float)a*(((float)b*(float)c)-(float)d)) out.println ("Solution found: "+a+"*(("+b+"*"+c+")-"+d+") = 24
"); rslt = (a*b*c)-d; if (rslt == 24 && rslt == ((float)a*(float)b*(float)c)-(float)d) out.println ("Solution found: ("+a+"*"+b+"*"+c+")-"+d+" = 24
"); rslt = (a*(b*c))-d; if (rslt == 24 && rslt == ((float)a*((float)b*(float)c))-(float)d) out.println ("Solution found: ("+a+"*("+b+"*"+c+"))-"+d+" = 24
"); rslt = a*b*c*d; if (rslt == 24 && rslt == (float)a*(float)b*(float)c*(float)d) out.println ("Solution found: "+a+"*"+b+"*"+c+"*"+d+" = 24
"); rslt = a*(b*c)*d; if (rslt == 24 && rslt == (float)a*((float)b*(float)c)*(float)d) out.println ("Solution found: "+a+"*("+b+"*"+c+")*"+d+" = 24
"); rslt = a*b*(c*d); if (rslt == 24 && rslt == (float)a*(float)b*((float)c*(float)d)) out.println ("Solution found: "+a+"*"+b+"*("+c+"*"+d+") = 24
"); rslt = a*(b*(c*d)); if (rslt == 24 && rslt == (float)a*((float)b*((float)c*(float)d))) out.println ("Solution found: "+a+"*("+b+"*("+c+"*"+d+")) = 24
"); rslt = a*((b*c)*d); if (rslt == 24 && rslt == (float)a*(((float)b*(float)c)*(float)d)) out.println ("Solution found: "+a+"*(("+b+"*"+c+")*"+d+") = 24
"); rslt = (a*b*c)*d; if (rslt == 24 && rslt == ((float)a*(float)b*(float)c)*(float)d) out.println ("Solution found: ("+a+"*"+b+"*"+c+")*"+d+" = 24
"); rslt = (a*(b*c))*d; if (rslt == 24 && rslt == ((float)a*((float)b*(float)c))*(float)d) out.println ("Solution found: ("+a+"*("+b+"*"+c+"))*"+d+" = 24
"); try { rslt = a*b*c/d; if (rslt == 24 && rslt == (float)a*(float)b*(float)c/(float)d) out.println ("Solution found: "+a+"*"+b+"*"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b*c)/d; if (rslt == 24 && rslt == (float)a*((float)b*(float)c)/(float)d) out.println ("Solution found: "+a+"*("+b+"*"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*b*(c/d); if (rslt == 24 && rslt == (float)a*(float)b*((float)c/(float)d)) out.println ("Solution found: "+a+"*"+b+"*("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b*(c/d)); if (rslt == 24 && rslt == (float)a*((float)b*((float)c/(float)d))) out.println ("Solution found: "+a+"*("+b+"*("+c+"/"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a*((b*c)/d); if (rslt == 24 && rslt == (float)a*(((float)b*(float)c)/(float)d)) out.println ("Solution found: "+a+"*(("+b+"*"+c+")/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*b*c)/d; if (rslt == 24 && rslt == ((float)a*(float)b*(float)c)/(float)d) out.println ("Solution found: ("+a+"*"+b+"*"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*(b*c))/d; if (rslt == 24 && rslt == ((float)a*((float)b*(float)c))/(float)d) out.println ("Solution found: ("+a+"*("+b+"*"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** * / ? ***/ try { rslt = a*b/c+d; if (rslt == 24 && rslt == (float)a*(float)b/(float)c+(float)d) out.println ("Solution found: "+a+"*"+b+"/"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b/c)+d; if (rslt == 24 && rslt == (float)a*((float)b/(float)c)+(float)d) out.println ("Solution found: "+a+"*("+b+"/"+c+")+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*b/(c+d); if (rslt == 24 && rslt == (float)a*(float)b/((float)c+(float)d)) out.println ("Solution found: "+a+"*"+b+"/("+c+"+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b/(c+d)); if (rslt == 24 && rslt == (float)a*((float)b/((float)c+(float)d))) out.println ("Solution found: "+a+"*("+b+"/("+c+"+"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a*((b/c)+d); if (rslt == 24 && rslt == (float)a*(((float)b/(float)c)+(float)d)) out.println ("Solution found: "+a+"*(("+b+"/"+c+")+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*b/c)+d; if (rslt == 24 && rslt == ((float)a*(float)b/(float)c)+(float)d) out.println ("Solution found: ("+a+"*"+b+"/"+c+")+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*(b/c))+d; if (rslt == 24 && rslt == ((float)a*((float)b/(float)c))/(float)d) out.println ("Solution found: ("+a+"*("+b+"/"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*b/c-d; if (rslt == 24 && rslt == (float)a*(float)b/(float)c-(float)d) out.println ("Solution found: "+a+"*"+b+"/"+c+"-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b/c)-d; if (rslt == 24 && rslt == (float)a*((float)b/(float)c)-(float)d) out.println ("Solution found: "+a+"*("+b+"/"+c+")-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*b/(c-d); if (rslt == 24 && rslt == (float)a*(float)b/((float)c-(float)d)) out.println ("Solution found: "+a+"*"+b+"/("+c+"-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b/(c-d)); if (rslt == 24 && rslt == (float)a*((float)b/((float)c-(float)d))) out.println ("Solution found: "+a+"*("+b+"/("+c+"-"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a*((b/c)-d); if (rslt == 24 && rslt == (float)a*(((float)b/(float)c)-(float)d)) out.println ("Solution found: "+a+"*(("+b+"/"+c+")-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*b/c)-d; if (rslt == 24 && rslt == ((float)a*(float)b/(float)c)-(float)d) out.println ("Solution found: ("+a+"*"+b+"/"+c+")-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*(b/c))-d; if (rslt == 24 && rslt == ((float)a*((float)b/(float)c))-(float)d) out.println ("Solution found: ("+a+"*("+b+"/"+c+"))-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*b/c*d; if (rslt == 24 && rslt == (float)a*(float)b/(float)c*(float)d) out.println ("Solution found: "+a+"*"+b+"/"+c+"*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b/c)*d; if (rslt == 24 && rslt == (float)a*((float)b/(float)c)*(float)d) out.println ("Solution found: "+a+"*("+b+"/"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*b/(c*d); if (rslt == 24 && rslt == (float)a*(float)b/((float)c*(float)d)) out.println ("Solution found: "+a+"*"+b+"/("+c+"*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b/(c*d)); if (rslt == 24 && rslt == (float)a*((float)b/((float)c*(float)d))) out.println ("Solution found: "+a+"*("+b+"/("+c+"*"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a*((b/c)*d); if (rslt == 24 && rslt == (float)a*(((float)b/(float)c)*(float)d)) out.println ("Solution found: "+a+"*(("+b+"/"+c+")*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*b/c)*d; if (rslt == 24 && rslt == ((float)a*(float)b/(float)c)*(float)d) out.println ("Solution found: ("+a+"*"+b+"/"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*(b/c))*d; if (rslt == 24 && rslt == ((float)a*((float)b/(float)c))*(float)d) out.println ("Solution found: ("+a+"*("+b+"/"+c+"))*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*b/c/d; if (rslt == 24 && rslt == (float)a*(float)b/(float)c/(float)d) out.println ("Solution found: "+a+"*"+b+"/"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b/c)/d; if (rslt == 24 && rslt == (float)a*((float)b/(float)c)/(float)d) out.println ("Solution found: "+a+"*("+b+"/"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a*b/(c/d); if (rslt == 24 && rslt == (float)a*(float)b/((float)c/(float)d)) out.println ("Solution found: "+a+"*"+b+"/("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a*(b/(c/d)); if (rslt == 24 && rslt == (float)a*((float)b/((float)c/(float)d))) out.println ("Solution found: "+a+"*("+b+"/("+c+"/"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a*((b/c)/d); if (rslt == 24 && rslt == (float)a*(((float)b/(float)c)/(float)d)) out.println ("Solution found: "+a+"*(("+b+"/"+c+")/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*b/c)/d; if (rslt == 24 && rslt == ((float)a*(float)b/(float)c)/(float)d) out.println ("Solution found: ("+a+"*"+b+"/"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a*(b/c))/d; if (rslt == 24 && rslt == ((float)a*((float)b/(float)c))/(float)d) out.println ("Solution found: ("+a+"*("+b+"/"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** / + + ***/ try { rslt = a/b+c+d; if (rslt == 24 && rslt == (float)a/(float)b+(float)c+(float)d) out.println ("Solution found: "+a+"/"+b+"+"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b+c+d); if (rslt == 24 && rslt == (float)a/((float)b+(float)c+(float)d)) out.println ("Solution found: "+a+"/("+b+"+"+c+"+"+d+") = 24
"); } catch (ArithmeticException e) { } /**** / + ? ***/ try { rslt = a/b+c-d; if (rslt == 24 && rslt == (float)a/(float)b+(float)c-(float)d) out.println ("Solution found: "+a+"/"+b+"+"+c+"-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b+c)-d; if (rslt == 24 && rslt == (float)a/((float)b+(float)c)-(float)d) out.println ("Solution found: "+a+"/("+b+"+"+c+")-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b+c)-d); if (rslt == 24 && rslt == (float)a/(((float)b+(float)c)-(float)d)) out.println ("Solution found: "+a+"/(("+b+"+"+c+")-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b+c*d; if (rslt == 24 && rslt == (float)a/(float)b+(float)c*(float)d) out.println ("Solution found: "+a+"/"+b+"+"+c+"*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b+c)*d; if (rslt == 24 && rslt == ((float)a/(float)b+(float)c)*(float)d) out.println ("Solution found: ("+a+"/"+b+"+"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b+c))*d; if (rslt == 24 && rslt == ((float)a/((float)b+(float)c))*(float)d) out.println ("Solution found: ("+a+"/("+b+"+"+c+"))*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b+c/d; if (rslt == 24 && rslt == (float)a/(float)b+(float)c/(float)d) out.println ("Solution found: "+a+"/"+b+"+"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b+c)/d; if (rslt == 24 && rslt == ((float)a/(float)b+(float)c)/(float)d) out.println ("Solution found: ("+a+"/"+b+"+"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b+c))/d; if (rslt == 24 && rslt == ((float)a/((float)b+(float)c))/(float)d) out.println ("Solution found: ("+a+"/("+b+"+"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** / - ? ***/ try { rslt = a/b-c+d; if (rslt == 24 && rslt == (float)a/(float)b-(float)c+(float)d) out.println ("Solution found: "+a+"/"+b+"-"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b-c)+d; if (rslt == 24 && rslt == (float)a/((float)b-(float)c)+(float)d) out.println ("Solution found: "+a+"/("+b+"-"+c+")+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b-(c+d); if (rslt == 24 && rslt == (float)a/(float)b-((float)c+(float)d)) out.println ("Solution found: "+a+"/"+b+"-("+c+"+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b-(c+d)); if (rslt == 24 && rslt == (float)a/((float)b-((float)c+(float)d))) out.println ("Solution found: "+a+"/("+b+"-("+c+"+"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b-c)+d); if (rslt == 24 && rslt == (float)a/(((float)b-(float)c)+(float)d)) out.println ("Solution found: "+a+"/(("+b+"-"+c+")+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b-c-d; if (rslt == 24 && rslt == (float)a/(float)b-(float)c-(float)d) out.println ("Solution found: "+a+"/"+b+"-"+c+"-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b-c)-d; if (rslt == 24 && rslt == (float)a/((float)b-(float)c)-(float)d) out.println ("Solution found: "+a+"/("+b+"-"+c+")-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b-(c-d); if (rslt == 24 && rslt == (float)a/(float)b-((float)c-(float)d)) out.println ("Solution found: "+a+"/"+b+"-("+c+"-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b-(c-d)); if (rslt == 24 && rslt == (float)a/((float)b-((float)c-(float)d))) out.println ("Solution found: "+a+"/("+b+"-("+c+"-"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b-c)-d); if (rslt == 24 && rslt == (float)a/(((float)b-(float)c)-(float)d)) out.println ("Solution found: "+a+"/(("+b+"-"+c+")-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b-c*d; if (rslt == 24 && rslt == (float)a/(float)b-(float)c*(float)d) out.println ("Solution found: "+a+"/"+b+"-"+c+"*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b-c)*d; if (rslt == 24 && rslt == (float)a/((float)b-(float)c)*(float)d) out.println ("Solution found: "+a+"/("+b+"-"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b-(c*d); if (rslt == 24 && rslt == (float)a/(float)b-((float)c*(float)d)) out.println ("Solution found: "+a+"/"+b+"-("+c+"*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b-(c*d)); if (rslt == 24 && rslt == (float)a/((float)b-((float)c*(float)d))) out.println ("Solution found: "+a+"/("+b+"-("+c+"*"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b-c)*d); if (rslt == 24 && rslt == (float)a/(((float)b-(float)c)*(float)d)) out.println ("Solution found: "+a+"/(("+b+"-"+c+")*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b-c)*d; if (rslt == 24 && rslt == ((float)a/(float)b-(float)c)*(float)d) out.println ("Solution found: ("+a+"/"+b+"-"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b-c))*d; if (rslt == 24 && rslt == ((float)a/((float)b-(float)c))*(float)d) out.println ("Solution found: ("+a+"/("+b+"-"+c+"))*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b-c/d; if (rslt == 24 && rslt == (float)a/(float)b-(float)c/(float)d) out.println ("Solution found: "+a+"/"+b+"-"+c+"/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b-c)/d; if (rslt == 24 && rslt == (float)a/((float)b-(float)c)/(float)d) out.println ("Solution found: "+a+"/("+b+"-"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b-(c/d); if (rslt == 24 && rslt == (float)a/(float)b-((float)c/(float)d)) out.println ("Solution found: "+a+"/"+b+"-("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b-(c/d)); if (rslt == 24 && rslt == (float)a/((float)b-((float)c/(float)d))) out.println ("Solution found: "+a+"/("+b+"-("+c+"/"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b-c)/d); if (rslt == 24 && rslt == (float)a/(((float)b-(float)c)/(float)d)) out.println ("Solution found: "+a+"/(("+b+"-"+c+")/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b-c)/d; if (rslt == 24 && rslt == ((float)a/(float)b-(float)c)/(float)d) out.println ("Solution found: ("+a+"/"+b+"-"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b-c))/d; if (rslt == 24 && rslt == ((float)a/((float)b-(float)c))/(float)d) out.println ("Solution found: ("+a+"/("+b+"-"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** / * ? ***/ try { rslt = a/b*c+d; if (rslt == 24 && rslt == (float)a/(float)b*(float)c+(float)d) out.println ("Solution found: "+a+"/"+b+"*"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b*c)+d; if (rslt == 24 && rslt == (float)a/((float)b*(float)c)+(float)d) out.println ("Solution found: "+a+"/("+b+"*"+c+")+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b*(c+d); if (rslt == 24 && rslt == (float)a/(float)b*((float)c+(float)d)) out.println ("Solution found: "+a+"/"+b+"*("+c+"+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b*(c+d)); if (rslt == 24 && rslt == (float)a/((float)b*((float)c+(float)d))) out.println ("Solution found: "+a+"/("+b+"*("+c+"+"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b*c)+d); if (rslt == 24 && rslt == (float)a/(((float)b*(float)c)+(float)d)) out.println ("Solution found: "+a+"/(("+b+"*"+c+")+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b*c)+d; if (rslt == 24 && rslt == ((float)a/(float)b*(float)c)+(float)d) out.println ("Solution found: ("+a+"/"+b+"*"+c+")+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b*c))+d; if (rslt == 24 && rslt == ((float)a/((float)b*(float)c))/(float)d) out.println ("Solution found: ("+a+"/("+b+"*"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b*c-d; if (rslt == 24 && rslt == (float)a/(float)b*(float)c-(float)d) out.println ("Solution found: "+a+"/"+b+"*"+c+"-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b*c)-d; if (rslt == 24 && rslt == (float)a/((float)b*(float)c)-(float)d) out.println ("Solution found: "+a+"/("+b+"*"+c+")-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b*(c-d); if (rslt == 24 && rslt == (float)a/(float)b*((float)c-(float)d)) out.println ("Solution found: "+a+"/"+b+"*("+c+"-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b*(c-d)); if (rslt == 24 && rslt == (float)a/((float)b*((float)c-(float)d))) out.println ("Solution found: "+a+"/("+b+"*("+c+"-"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b*c)-d); if (rslt == 24 && rslt == (float)a/(((float)b*(float)c)-(float)d)) out.println ("Solution found: "+a+"/(("+b+"*"+c+")-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b*c)-d; if (rslt == 24 && rslt == ((float)a/(float)b*(float)c)-(float)d) out.println ("Solution found: ("+a+"/"+b+"*"+c+")-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b*c))-d; if (rslt == 24 && rslt == ((float)a/((float)b*(float)c))-(float)d) out.println ("Solution found: ("+a+"/("+b+"*"+c+"))-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b*c*d; if (rslt == 24 && rslt == (float)a/(float)b*(float)c*(float)d) out.println ("Solution found: "+a+"/"+b+"*"+c+"*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b*c)*d; if (rslt == 24 && rslt == (float)a/((float)b*(float)c)*(float)d) out.println ("Solution found: "+a+"/("+b+"*"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b*(c*d); if (rslt == 24 && rslt == (float)a/(float)b*((float)c*(float)d)) out.println ("Solution found: "+a+"/"+b+"*("+c+"*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b*(c*d)); if (rslt == 24 && rslt == (float)a/((float)b*((float)c*(float)d))) out.println ("Solution found: "+a+"/("+b+"*("+c+"*"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b*c)*d); if (rslt == 24 && rslt == (float)a/(((float)b*(float)c)*(float)d)) out.println ("Solution found: "+a+"/(("+b+"*"+c+")*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b*c)*d; if (rslt == 24 && rslt == ((float)a/(float)b*(float)c)*(float)d) out.println ("Solution found: ("+a+"/"+b+"*"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b*c))*d; if (rslt == 24 && rslt == ((float)a/((float)b*(float)c))*(float)d) out.println ("Solution found: ("+a+"/("+b+"*"+c+"))*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b*c/d; if (rslt == 24 && rslt == (float)a/(float)b*(float)c/(float)d) out.println ("Solution found: "+a+"/"+b+"*"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b*c)/d; if (rslt == 24 && rslt == (float)a/((float)b*(float)c)/(float)d) out.println ("Solution found: "+a+"/("+b+"*"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b*(c/d); if (rslt == 24 && rslt == (float)a/(float)b*((float)c/(float)d)) out.println ("Solution found: "+a+"/"+b+"*("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b*(c/d)); if (rslt == 24 && rslt == (float)a/((float)b*((float)c/(float)d))) out.println ("Solution found: "+a+"/("+b+"*("+c+"/"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b*c)/d); if (rslt == 24 && rslt == (float)a/(((float)b*(float)c)/(float)d)) out.println ("Solution found: "+a+"/(("+b+"*"+c+")/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b*c)/d; if (rslt == 24 && rslt == ((float)a/(float)b*(float)c)/(float)d) out.println ("Solution found: ("+a+"/"+b+"*"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b*c))/d; if (rslt == 24 && rslt == ((float)a/((float)b*(float)c))/(float)d) out.println ("Solution found: ("+a+"/("+b+"*"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } /**** * / ? ***/ try { rslt = a/b/c+d; if (rslt == 24 && rslt == (float)a/(float)b/(float)c+(float)d) out.println ("Solution found: "+a+"/"+b+"/"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b/c)+d; if (rslt == 24 && rslt == (float)a/((float)b/(float)c)+(float)d) out.println ("Solution found: "+a+"/("+b+"/"+c+")+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b/(c+d); if (rslt == 24 && rslt == (float)a/(float)b/((float)c+(float)d)) out.println ("Solution found: "+a+"/"+b+"/("+c+"+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b/(c+d)); if (rslt == 24 && rslt == (float)a/((float)b/((float)c+(float)d))) out.println ("Solution found: "+a+"/("+b+"/("+c+"+"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b/c)+d); if (rslt == 24 && rslt == (float)a/(((float)b/(float)c)+(float)d)) out.println ("Solution found: "+a+"/(("+b+"/"+c+")+"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b/c)+d; if (rslt == 24 && rslt == ((float)a/(float)b/(float)c)+(float)d) out.println ("Solution found: ("+a+"/"+b+"/"+c+")+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b/c))+d; if (rslt == 24 && rslt == ((float)a/((float)b/(float)c))/(float)d) out.println ("Solution found: ("+a+"/("+b+"/"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b/c-d; if (rslt == 24 && rslt == (float)a/(float)b/(float)c-(float)d) out.println ("Solution found: "+a+"/"+b+"/"+c+"-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b/c)-d; if (rslt == 24 && rslt == (float)a/((float)b/(float)c)-(float)d) out.println ("Solution found: "+a+"/("+b+"/"+c+")-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b/(c-d); if (rslt == 24 && rslt == (float)a/(float)b/((float)c-(float)d)) out.println ("Solution found: "+a+"/"+b+"/("+c+"-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b/(c-d)); if (rslt == 24 && rslt == (float)a/((float)b/((float)c-(float)d))) out.println ("Solution found: "+a+"/("+b+"/("+c+"-"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b/c)-d); if (rslt == 24 && rslt == (float)a/(((float)b/(float)c)-(float)d)) out.println ("Solution found: "+a+"/(("+b+"/"+c+")-"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b/c)-d; if (rslt == 24 && rslt == ((float)a/(float)b/(float)c)-(float)d) out.println ("Solution found: ("+a+"/"+b+"/"+c+")-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b/c))-d; if (rslt == 24 && rslt == ((float)a/((float)b/(float)c))-(float)d) out.println ("Solution found: ("+a+"/("+b+"/"+c+"))-"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b/c*d; if (rslt == 24 && rslt == (float)a/(float)b/(float)c*(float)d) out.println ("Solution found: "+a+"/"+b+"/"+c+"*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b/c)*d; if (rslt == 24 && rslt == (float)a/((float)b/(float)c)*(float)d) out.println ("Solution found: "+a+"/("+b+"/"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b/(c*d); if (rslt == 24 && rslt == (float)a/(float)b/((float)c*(float)d)) out.println ("Solution found: "+a+"/"+b+"/("+c+"*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b/(c*d)); if (rslt == 24 && rslt == (float)a/((float)b/((float)c*(float)d))) out.println ("Solution found: "+a+"/("+b+"/("+c+"*"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b/c)*d); if (rslt == 24 && rslt == (float)a/(((float)b/(float)c)*(float)d)) out.println ("Solution found: "+a+"/(("+b+"/"+c+")*"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b/c)*d; if (rslt == 24 && rslt == ((float)a/(float)b/(float)c)*(float)d) out.println ("Solution found: ("+a+"/"+b+"/"+c+")*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b/c))*d; if (rslt == 24 && rslt == ((float)a/((float)b/(float)c))*(float)d) out.println ("Solution found: ("+a+"/("+b+"/"+c+"))*"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b/c/d; if (rslt == 24 && rslt == (float)a/(float)b/(float)c/(float)d) out.println ("Solution found: "+a+"/"+b+"/"+c+"+"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b/c)/d; if (rslt == 24 && rslt == (float)a/((float)b/(float)c)/(float)d) out.println ("Solution found: "+a+"/("+b+"/"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = a/b/(c/d); if (rslt == 24 && rslt == (float)a/(float)b/((float)c/(float)d)) out.println ("Solution found: "+a+"/"+b+"/("+c+"/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = a/(b/(c/d)); if (rslt == 24 && rslt == (float)a/((float)b/((float)c/(float)d))) out.println ("Solution found: "+a+"/("+b+"/("+c+"/"+d+")) = 24
"); } catch (ArithmeticException e) { } try { rslt = a/((b/c)/d); if (rslt == 24 && rslt == (float)a/(((float)b/(float)c)/(float)d)) out.println ("Solution found: "+a+"/(("+b+"/"+c+")/"+d+") = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/b/c)/d; if (rslt == 24 && rslt == ((float)a/(float)b/(float)c)/(float)d) out.println ("Solution found: ("+a+"/"+b+"/"+c+")/"+d+" = 24
"); } catch (ArithmeticException e) { } try { rslt = (a/(b/c))/d; if (rslt == 24 && rslt == ((float)a/((float)b/(float)c))/(float)d) out.println ("Solution found: ("+a+"/("+b+"/"+c+"))/"+d+" = 24
"); } catch (ArithmeticException e) { } } // End checkSolutions() }