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. Application which takes your marks of six subjects from the client side and displays the percentage that you have obtained

  2. Program to show the use of Nested If-Else Statements

  3. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  4. Even number ,Prime no. ,Factorial of a number

  5. Program to show some properties of StringBuffer object

  6. Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet

  7. Program to show the use of If Statement

  8. An applet program to take user input and display

  9. Program to declare, initialize and print an array of characters

  10. Program sets up a String variable containing a paragraph of text of your choice. Extract the words from the text and sort them into alphabetical order

  11. Program to show the use of While Loop

  12. An applet program to display alternate filled and empty circle that to in row and column format

  13. Program to show an example of Driving and using a Class

  14. Program of date server and client

  15. Write a class whose objects holds a current value and have a method to add that value, printing the new value

  16. Program to read input from the Standard Input Device

  17. Create an interface coversions. Which have the following functions Inchestomillimeters(), hptowatts(),wattstohp(),poundstogram(),gramtopounds()

  18. Program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7

  19. Corba program of Count Client Applet, IDL,Server, Client

  20. Program to print triangle of numbers