<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-22664755</id><updated>2011-12-14T19:13:26.700-08:00</updated><title type='text'>Java Programming Hints And Tips</title><subtitle type='html'>hai,
    This contains  some of the java programs</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sonilalith.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22664755/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sonilalith.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>LALITH</name><uri>http://www.blogger.com/profile/04699775274137170226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-22664755.post-114050622490143593</id><published>2006-02-20T23:02:00.000-08:00</published><updated>2006-02-21T22:21:19.413-08:00</updated><title type='text'></title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; PROGRAM IS TO CONVERT&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;AN INFIX NOTATION TO POSTFIX&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;import java.io.BufferedReader;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;import java.io.InputStreamReader;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;import java.io.IOException;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;import java.util.StringTokenizer;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;* This program is a very simple calculator that you can type infix&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;* expressions of the form "29 + 45 + 3 - 20" into and it will evaluate&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;* them by adding up or subtracting the numbers, to give you a total.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;*&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;**/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;public class SimpleCalc&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt; /**&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  * This is the main entry point for the calculator - it reads an&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  * expression from the user, evaluates it and prints out the result.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  *&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  **/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt; public static void main( String argv[] )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   String expression;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   int result;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   expression = readExpression();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   result = evaluate( expression );&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   System.out.println( "Total: " + result );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt; /**&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  * Read a text string containing the expression to be evaluated.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  *&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  * @return the string that the user entered&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  *&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  **/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt; public static String readExpression()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   BufferedReader keyboard = new BufferedReader( new InputStreamReader( System.in ) );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   String expression = "";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   System.out.print( "Please enter the expression: " );&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     expression = keyboard.readLine();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   catch ( IOException error )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     // There is a problem reading from the keyboard&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     System.err.println( "Error reading from the keyboard: " + error );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     System.exit( 1 );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   return expression;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt; /**&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  * Evaluate the expression passed in as a parameter and return&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  * the result.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  *&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  * @param expression  the expression to evaluate&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  * @return the result of the expression&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  *&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;  **/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt; public static int evaluate( String expression )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   StringTokenizer tokenizedExpression = new StringTokenizer( expression );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   // we're expecting a number at the start of the expression&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   boolean expectingOperator = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   // start with a '+' here because we want to add the very first number&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   char operator = '+';&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   int total = 0;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   while ( tokenizedExpression.hasMoreTokens() )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     String symbol = tokenizedExpression.nextToken();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     // **** Is it an operator?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     if ( symbol.equals( "+" ) || symbol.equals( "-" ) )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;       {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;       if ( expectingOperator )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         // use charAt() to convert it from a string ("+") to a single char ('+')&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         operator = symbol.charAt( 0 );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         // just had an operator, so we're expecting an operand next&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         expectingOperator = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;       else&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         System.err.println( "Error in format of expression: a number expected." );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         System.exit( 1 );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     // **** Then it must be an operand&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     else&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;       {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;       if ( expectingOperator )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         System.err.println( "Error in format of expression: an operator is expected." );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         System.exit( 1 );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;       else&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         int operand = 0;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           operand = Integer.parseInt( symbol );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         catch ( NumberFormatException e )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           System.err.println( "Error in format of expression: number expected." );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           System.exit( 1 );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           }&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         switch ( operator )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           case '+':&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;             total = total + operand;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;             break;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           case '-':&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;             total = total - operand;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;             break;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;           }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         // just had an operand, so we're expecting an operator next&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         expectingOperator = true;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;         }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;       }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;     }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   return total;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;   }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt; }&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22664755-114050622490143593?l=sonilalith.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sonilalith.blogspot.com/feeds/114050622490143593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=22664755&amp;postID=114050622490143593' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22664755/posts/default/114050622490143593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22664755/posts/default/114050622490143593'/><link rel='alternate' type='text/html' href='http://sonilalith.blogspot.com/2006/02/program-is-to-convert-infix-notation.html' title=''/><author><name>LALITH</name><uri>http://www.blogger.com/profile/04699775274137170226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22664755.post-114032954019041101</id><published>2006-02-18T22:10:00.000-08:00</published><updated>2006-02-24T06:59:54.153-08:00</updated><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(255, 153, 0);font-family:arial;font-size:180%;"  &gt;About Me:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 204, 204);font-size:130%;" &gt;&lt;span style="font-family:verdana;"&gt;        Name:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;        Lalith Kumar Soni&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;        Location:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;        Hyderabad, Andhra Pradesh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;        India&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Hi, I am Lalith Kumar Soni, &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;pursuing my Masters Of Computer&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Aplication at JNT University,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Hyderabad...........&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22664755-114032954019041101?l=sonilalith.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sonilalith.blogspot.com/feeds/114032954019041101/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=22664755&amp;postID=114032954019041101' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22664755/posts/default/114032954019041101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22664755/posts/default/114032954019041101'/><link rel='alternate' type='text/html' href='http://sonilalith.blogspot.com/2006/02/about-me-name-lalith-kumar-soni.html' title=''/><author><name>LALITH</name><uri>http://www.blogger.com/profile/04699775274137170226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
