Java Blog

 
 
 
import java.io.*;

class  Inventor
{
    public static void main(String args[]) 
    {
       final String ans=\"BJARNE STROUSTRUP\";
       String str;
       int n=3,attempt=0;

       try{
          BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));

          while(n>0)
          {
              System.out.print(\"Who is Founder of C++ : \");
              System.out.flush();
              str=obj.readLine();
              attempt++;
              if( str.equalsIgnoreCase(ans) == true)
              {
                     if(attempt==1)
                     {
                         System.out.println(\"\\nVERY GOOD\");
                         System.exit(1);
                     }
                     else if(attempt==2)
                      {
                         System.out.println(\"\\nGOOD\");
                         System.exit(1);
                      }
                     else
                      {
                         System.out.println(\"CORRECT\");
                         System.exit(1);
                      }
            }
            else
                   System.out.println(\"\\nTRY AGAIN\\n\");

            n=n-1;
         }
         if(attempt>=3)
            System.out.println(\"\\nANSWER IS \"+ans);
        }
    catch(Exception e) {}
    }
}

    Related Post:
  1. Program of creating a file using text fields in windows

  2. An applet program of showing new document using showDocument(URL) method

  3. Develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side, executed on server

  4. program which takes a long sentence from the client passes to the server,server separates out each word and sends them back to client in reverse order

  5. An application that combines several classes and interface

  6. Program to generate SQUARE ROOT table

  7. Program to show an example of using initialization block to initialize the data members of a class

  8. Program to show the use of Bitwise Operator (|) OR

  9. Program to show an example of using a Static Nested Class outside the Top-Level Class

  10. Program to read command line arguments

  11. Program to read input from the Standard Input Device

  12. Program to show an example of Concatination of Strings

  13. Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01

  14. Program to declare and initialize Boolean variables and print them on the Standard Output Device

  15. Write a program for restaurant

  16. Program to extract a portion of a character string and print the extracted string

  17. An applet program to find maximum of three numbers using textField

  18. CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side

  19. Program to show the use of If-Else Statement

  20. Program to show insertion of StringBuffer, String objects and other Basic Data Types into a StringBuffer object