Skip to content →

An online Java Compiler

You can ‘Run’ your java code online, even if you dont have a compiler at your disposal, over here:- http://www.zamples.com/JspExplorer/index.jsp?format=jdk16cl

[update] Here is an online compiler for C#, Java, c++, Visual Basic (VB), Fortran, PHP, Perl, Ruby and many others!

CodePad is a an online compiler/interpreter with simple collaboration too.

You can paste your code to IDEOne to further compile and run.

Published in Featured

72 Comments

  1. sirisha sirisha

    Need to compile in jdk 1.2.2

    • raviteja raviteja

      sorry I don’t knwo

      • Himachaliboy Amarjeet Himachaliboy Amarjeet

        Sam r u run this program?????

      • jose terer jose terer

        public class Bicycle {

        // the Bicycle class has three fields
        public int cadence;
        public int gear;
        public int speed;

        // the Bicycle class has one constructor
        public Bicycle(int start Cadence, int start Speed, int start Gear) {
        gear = start Gear;
        cadence = start Cadence;
        speed = start Speed;
        }

        // the Bicycle class has four methods
        public void set Cadence(int new Value) {
        cadence = new Value;
        }

        public void set Gear(int new Value) {
        gear = new Value;
        }

        public void apply Brake(int decrement) {
        speed -= decrement;
        }

        public void speed Up(int increment) {
        speed += increment;
        }

        }

  2. Sam Sam

    import java.util.*;
    import java.lang.*;
    public String getVal(String val){

    if(val != null && vl.trim().length()>0)
    return val.trim();
    return “Siva”.trim();

    }

    class StrTest{

    public static void main(String args[]){

    String n = ” “;
    String s = getVal(n);
    System.out.println(s);

    }

    }

    • KID KID

      import java.util.*;
      import java.lang.*;
      public String getVal(String val){

      if(val != null && vl.trim().length()>0)
      return val.trim();
      return “Siva”.trim();

      }

      class StrTest{

      public static void main(String args[]){

      String n = ” “;
      String s = getVal(n);
      System.out.println(s);

      }

      }

  3. GamerPsyche GamerPsyche

    I usually use the one at MethodGamer.com
    It’s fairly simple and easy to use and is constantly undergoing development.
    They are supposedly looking for developers as well and you do not have to worry about the safety of your code as they do not save the code on their servers but allow you to save it on your own computer.
    That’s the only one I know of though.

    • varun varun

      class Multiplication
      {

      public static void main (String[] a)
      {
      int num = Integer.parseInt(a[0]);

      for( int i=1;i<=10;i++)
      System.out.println(i*num);
      }

      }

      when i am trying to execute this program there is no compliation error,but i am getting this error
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at Multiplication.main(Main.java:6)
      what to do,something prblm is in array,how to execute this,i am a beginner in java,please tell me what is the prblm

      • Jonatas Jonatas

        try this:
        class Multiplication
        {

        public static void main (String[] a)
        {
        int num = Integer.parseInt(a[0]);

        for( int i=1;i<10;i++) //without =
        System.out.println(i*num);
        }

        }

      • raghuraj raghuraj

        u r for loop wring just make it as a for(int i=0;i<10;i++)

      • NIRANJAN NIRANJAN

        you will give value at run time.
        eg. run in DOS then
        javac Multiplication.java
        java Multiplication 1

      • aaa aaa

        class Multiplication
        {

        public static void main (String[] a)
        {
        String as[]={“1″,”5″,”4″,”7″,”8″,”5″,”9″,”5″,”8″,”4″,”5”};
        int num = Integer.parseInt(as[0]);

        for( int i=1;i<=10;i++)
        System.out.println(i*num);
        }

        }

        will work dude.

    • ASasASas ASasASas

      class Pop
      {
      public static void main (String[] a)
      {

      if (a.length > 0)
      {

      try{
      int num = Integer.parseInt(a[0]);

      for( int i=1;i<=10;i++)
      System.out.println(i*num);
      }catch (NumberFormatException E)

      {
      System.out.println("Only Numbers are allowed as a cmd line Argument");
      return;
      }//catch
      }//if

      else {System.out.println("No input Supplied");}

      }//main
      }//Class

    • Mac Mac

      This doesn’t work .. on Hitting the Debug/Run button , it gives the error Method Not Allowed on the default program >> Test.java

      • kannadasan kannadasan

        hi, Mac! your program should be renamed in the format “classname.java”. for eg, if the name of the class in your program is phenom, then you should rename it as “phenom.java”. after doing so, run your program. it’ll work.sorry, if i’m wrong.

      • aaa aaa

        It’s not necessary dat class name and file name should have same name.
        It just for progarammers ease. Try it dude.
        It means, “XYZ.java” having code :

        class abc
        {
        }

        will compile n execute sucessfully.

  4. Abdul Majeed Abdul Majeed

    nice oneeee

  5. 2reams 2reams

    //disply string in different front and colour
    import java.awt.front;
    import java.awt.colour;
    import java.awt.graphics;
    import.javax.swing.jpanel;
    public class ForntPanel extends Jpanel
    {
    //display strings in different front and colour
    public void paintComponet( Graphic g )
    {
    super.paintComponet( g ); // call superclass’s paintComponet

    //set font to serif (Times),bold, 12pt and draw a string
    g.setFront(new Front( “serife”,Front.Bold, 12) );
    g. drawString(“serif 12 point bolg.”,20,50);

    //set front to monospaced (courier),italic, 24pt and draw a string
    g.setfront(new Front( “monospaced”, Front.ITALIC, 24) );
    g.drawstring( “monospaced 24 point italic.”, 20, 70 );

    //set front to SansSerif (Helvetica), plain, 14pt and draw a string
    g.setFront(ne3w Front(“SansSerif”, front.PLAIN, 14) );
    g.drawString( “SansSerif 14 point plain.”, 20, 90 );
    //set front toSerif (Times), bold/italic, 18pt and draw a string
    g.setColour(Colour.RED);
    g.setFront(new Front( “Serif”,font.BOLD+font.ITALIC, 18) );
    g.drawString( g.grtFront().getName +” “+ g.getFont().getSize()+”point bold italic.”, 20, 110 );
    }//end method paintComponet
    }//end class FontJPanel

  6. harsha harsha

    //Hide password from command line

    import java.io.BufferedReader;
    import java.io.InputStreamReader;

    public class HidePasswordFromCommandLine extends Thread {
    boolean stopThread = false;
    boolean hideInput = false;
    boolean shortMomentGone = false;

    public void run() {
    try {
    sleep( 500 );
    }
    catch( InterruptedException e ) {
    }
    shortMomentGone = true;
    while( !stopThread ) {
    if( hideInput ) {
    System.out.print( “\b*” );
    }
    try {
    sleep( 1 );
    }
    catch( InterruptedException e ) {
    }
    }
    }

    public static void main( String[] arguments ) {
    String name = “”;
    String password = “”;
    HidePasswordFromCommandLine hideThread = new HidePasswordFromCommandLine();
    hideThread.start();
    BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
    try {
    System.out.println( “Name: ” );
    // Wait for the username and clear the keyboard buffer (if neccessarry)
    do {
    name = in.readLine();
    } while( hideThread.shortMomentGone == false );

    // Now the hide thread should begin to overwrite any input with “*”
    hideThread.hideInput = true;

    // Read the password
    System.out.println( “\nPassword:” );
    System.out.print( ” ” );
    password = in.readLine();
    hideThread.stopThread = true;
    }
    catch( Exception e ) {
    }
    System.out.print( “\b \b” );
    // JUST FOR TESTING – PLEASE DELETE!
    System.out.println( “\n\nLogin= ” + name );
    System.out.println( “Password= ” + password );
    }
    }

  7. Thanks for IDE its really helpful

  8. sushma jadhav sushma jadhav

    please information about the online compiler or centrelise compiler

  9. Dila Ram Dila Ram

    i want to know what is the use of setMenuBar() method if we can perform the same functionality using add() method in java (AWT);

  10. arvind kumar arvind kumar

    Thanks a lot all contributer of http://www.youjavait.com
    I want to know that how can i compile and execute a simple chat client server program.

  11. suresh suresh

    import java.io.*;
    class Link
    {
        public int data1;
        public double data2;
        public Link nextLink;
        //Link constructor
        public Link(int d1, double d2) {
                data1 = d1;
                data2 = d2;
        }
        //Print Link data
        public void printLink() {
                System.out.print(“{” + data1 + “, ” + data2 + “} “);
        }
    }
    class LinkList {
        private Link first;
        //LinkList constructor
        public LinkList() {
                first = null;
        }
        //Returns true if list is empty
        public boolean isEmpty() {
                return first == null;
        }
        //Inserts a new Link at the first of the list
        public void insert(int d1, double d2) {
                Link link = new Link(d1, d2);
                link.nextLink = first;
                first = link;
        }
        //Deletes the link at the first of the list
        public Link delete() {
                Link temp = first;
                first = first.nextLink;
                return temp;
        }
        //Prints list data
        public void printList() {
                Link currentLink = first;
                System.out.print(“List: “);
                while(currentLink != null) {
                        currentLink.printLink();
                        currentLink = currentLink.nextLink;
                }
                System.out.println(“”);
        }
    }  
    class LinkListTest {
        public static void main(String[] args) {
                LinkList list = new LinkList();
                list.insert(1, 1.01);
                list.insert(2, 2.02);
                list.insert(3, 3.03);
                list.insert(4, 4.04);
                list.insert(5, 5.05);
                list.printList();
                while(!list.isEmpty()) {
                        Link deletedLink = list.delete();
                        System.out.print(“deleted: “);
                        deletedLink.printLink();
                        System.out.println(“”);
                }
                list.printList();
        }
    }

  12. krishna krishna

    i would like to use online compiler of java

  13. oncompiler oncompiler

    import java.io.*;
    class Link
    {
    public int data1;
    public double data2;
    public Link nextLink;
    //Link constructor
    public Link(int d1, double d2) {
    data1 = d1;
    data2 = d2;
    }
    //Print Link data
    public void printLink() {
    System.out.print(“{” + data1 + “, ” + data2 + “} “);
    }
    }
    class LinkList {
    private Link first;
    //LinkList constructor
    public LinkList() {
    first = null;
    }
    //Returns true if list is empty
    public boolean isEmpty() {
    return first == null;
    }
    //Inserts a new Link at the first of the list
    public void insert(int d1, double d2) {
    Link link = new Link(d1, d2);
    link.nextLink = first;
    first = link;
    }
    //Deletes the link at the first of the list
    public Link delete() {
    Link temp = first;
    first = first.nextLink;
    return temp;
    }
    //Prints list data
    public void printList() {
    Link currentLink = first;
    System.out.print(“List: “);
    while(currentLink != null) {
    currentLink.printLink();
    currentLink = currentLink.nextLink;
    }
    System.out.println(“”);
    }
    }
    class LinkListTest {
    public static void main(String[] args) {
    LinkList list = new LinkList();
    list.insert(1, 1.01);
    list.insert(2, 2.02);
    list.insert(3, 3.03);
    list.insert(4, 4.04);
    list.insert(5, 5.05);
    list.printList();
    while(!list.isEmpty()) {
    Link deletedLink = list.delete();
    System.out.print(“deleted: “);
    deletedLink.printLink();
    System.out.println(“”);
    }
    list.printList();
    }
    }

  14. can you give me an example of running java program?plz….

  15. ethel fajardo ethel fajardo

    It should be classname.java:
    you should add this line:

    import java.ulit.*;—–> this line should do the job.
    import java.io.*;
    class Link
    {
    public int data1;
    public double data2;
    public Link nextLink;
    //Link constructor
    public Link(int d1, double d2) {
    data1 = d1;
    data2 = d2;
    }
    //Print Link data
    public void printLink() {
    System.out.print(“{” + data1 + “, ” + data2 + “} “);
    }
    }
    class LinkList {
    private Link first;
    //LinkList constructor
    public LinkList() {
    first = null;
    }
    //Returns true if list is empty
    public boolean isEmpty() {
    return first == null;
    }
    //Inserts a new Link at the first of the list
    public void insert(int d1, double d2) {
    Link link = new Link(d1, d2);
    link.nextLink = first;
    first = link;
    }
    //Deletes the link at the first of the list
    public Link delete() {
    Link temp = first;
    first = first.nextLink;
    return temp;
    }
    //Prints list data
    public void printList() {
    Link currentLink = first;
    System.out.print(“List: “);
    while(currentLink != null) {
    currentLink.printLink();
    currentLink = currentLink.nextLink;
    }
    System.out.println(“”);
    }
    }
    class LinkListTest {
    public static void main(String[] args) {
    LinkList list = new LinkList();
    list.insert(1, 1.01);
    list.insert(2, 2.02);
    list.insert(3, 3.03);
    list.insert(4, 4.04);
    list.insert(5, 5.05);
    list.printList();
    while(!list.isEmpty()) {
    Link deletedLink = list.delete();
    System.out.print(“deleted: “);
    deletedLink.printLink();
    System.out.println(“”);
    }
    list.printList();
    }
    }

  16. This in an online free java compiler that present results in realtime via ajax. It also work with threads :)

  17. asss asss

    import assss

  18. kunal kunal

    java cmdline Java is wonderful
    class cmdline
    {
    public static void main(String args[])
    {
    System.out.println(“Number of arguments : “+args.length);
    for(int i=0;i<args.length;i++)
    System.out.print(args[i]+” “);
    }
    }

    // what will be the output ?????

    • kunal kunal

      ans = is wonderful

  19. kunal kunal

    java cmdline Java is wonderful
    class cmdline
    {
    public static void main(String args[])
    {
    System.out.println(“Number of arguments : “+args.length);
    for(int i=0;i<args.length;i++)
    System.out.print(args[i]+” “);
    }
    }

    // what will be the output ?????
    Reply me asap

    • Himachaliboy Amarjeet Himachaliboy Amarjeet

      class cmdline
      {
      public static void main(String args[])
      {
      System.out.println(“Number of arguments : “+args.length);
      for(int i=0;i> NUMBER OF ARGUMENTS : 0

  20. rajesh m rajesh m

    there’s already tons of java programs you can compile & run directly online at http://www.krazykoder.com

    it allows you to run java console programs as well as java webapps (jsps, servlets, struts, ..) online.

    moreover, when a new user views your program, he can modify it online and enhance it further too.

    (the original program doesnt get affected as the new user gets a temporary copy of it)

    if my writing is too confusing, just head on to http://www.krazykoder and run a few programs, you’ll get what im talking about :)

  21. Mohammad Mohammad

    hi :
    how i can create next(button) >>> when i click it so, give me another frame but in the same it frame ( target it self) >>>>>>>>>

    or how i can create slide of pages in java application

  22. srinivas.r srinivas.r

    during java code compilation it shows
    C:\Program Files\Java\jdk1.7.0\bin>javac Prg04.java
    Note: Prg04.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    how can i solve this and run the code???

  23. swetha swetha

    help please
    Construct a complete program that consists of 2 classes, mainTriangle and Triangle and 1 object, tri that contains the following information:
    Data : base (double) ? set the value to 4.2
    height (double) ? set the value to 9.0
    area (double)
    Method : double calculateArea() ? calculate area = ½ (base * height )
    void displayArea(double area) ? display the area

  24. swetha swetha

    can anyone help with this question please
    Construct a complete program that consists of 2 classes, mainTriangle and Triangle and 1 object, tri that contains the following information:
    Data : base (double) ? set the value to 4.2
    height (double) ? set the value to 9.0
    area (double)
    Method : double calculateArea() ? calculate area = ½ (base * height )
    void displayArea(double area) ? display the area

  25. surabi surabi

    hiii frnds… im a begineer of java…. can u pls suggest me how to start with programs… with makes efficient learning of programming…..:)

  26. anonymous anonymous

    These links don’t work anymore :\

  27. Himachaliboy Amarjeet Himachaliboy Amarjeet

    Plz check it

    class WithoutMain
    {
    static
    {
    System.out.println(“This java program ran without the main method”);
    }
    }

    • khan29 khan29

      yes it will give u output coz static method runs before main method

  28. Himachaliboy Amarjeet Himachaliboy Amarjeet

    not error but chect it

    class CL
    {
    public static void main(String args[])
    {
    outer: for (int i=0; i<100000; i++)
    {
    for(int j=0; j i)
    {
    System.out.println();
    continue outer;
    }
    System.out.print(” ” + (i * j));
    }
    }
    System.out.println();
    }
    }

  29. Shashank Shashank

    class Multiplication
    {
    public static void main (String[] a)
    {

    if (a.length > 0)
    {

    try{
    int num = Integer.parseInt(a[0]);

    for( int i=1;i<=10;i++)
    System.out.println(i*num);
    }catch (NumberFormatException E)

    {
    System.out.println("Only Numbers are allowed as a cmd line Argument");
    return;
    }//catch
    }//if

    else {System.out.println("No input Supplied");}

    }//main
    }//Class

  30. Shashank Shashank

    class Pop
    {
    public static void main (String[] a)
    {

    if (a.length > 0)
    {

    try{
    int num = Integer.parseInt(a[0]);

    for( int i=1;i<=10;i++)
    System.out.println(i*num);
    }catch (NumberFormatException E)

    {
    System.out.println("Only Numbers are allowed as a cmd line Argument");
    return;
    }//catch
    }//if

    else {System.out.println("No input Supplied");}

    }//main
    }//Class

  31. Mohafiz Mohafiz

    class y

    {

    static String Acc=”Accenture”;

    static int num1=57;

    static

    {

    System.out.println(Acc);

    System.out.println(num1++ + –num1);

    }

    public static void main(String args[])

    {

    System.out.println(” “+Acc+num1);

    }
    }

  32. haider haider

    import java.util.concurrent.ExecutionException;

    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.Spinner;
    import android.widget.Toast;
    import de.bsd.zwitscher.R;
    import de.bsd.zwitscher.TabWidget;
    import de.bsd.zwitscher.TweetDB;
    import de.bsd.zwitscher.Tokens;
    import de.bsd.zwitscher.TwitterHelper;
    import de.bsd.zwitscher.helper.NetworkHelper;

    public class LoginActivity extends Activity {

    private TweetDB tweetDB;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    tweetDB = TweetDB.getInstance(getApplicationContext());
    }

    /**
    * Check if we already have access tokens. If so just proceed to the
    * TabWidget. Otherwise check if xAuth is supported or not and show the
    * respective input screen layout.
    */
    @Override
    protected void onResume() {
    super.onResume();

    Account account = tweetDB.getDefaultAccount();
    if (account != null) {
    proceed(account);
    return;
    }

    /*
    * We have no valid account yet, so first check if the user has networking,
    * as networking is needed for initial login.
    */
    NetworkHelper nh = new NetworkHelper(this);
    if (!nh.isOnline()) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(“You seem to be offline. Please turn on networking and come back.”)
    .setCancelable(false)
    .setPositiveButton(“OK”, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int id) {
    dialog.cancel();
    LoginActivity.this.finish();
    }
    });
    AlertDialog alert = builder.create();
    alert.show();
    }

    // TODO change this here, as identi.ca / status.net has nothing to do with Twitter xauth/oauth
    if (Tokens.xAuthEnabled) { // TODO what about identi.ca
    // etc? -> 2 step 1st type
    // 2nd user/pass
    setContentView(R.layout.login_layout_classic);
    } else {
    setContentView(R.layout.login_layout);
    }
    }

    /**
    * Triggers a call to the twitter auth url, where the user will login using
    * username and password and get a pin back
    *
    * @param v
    */
    @SuppressWarnings(“unused”)
    public void getPinButton(View v) {
    Intent i = new Intent(Intent.ACTION_VIEW);

    TwitterHelper th = new TwitterHelper(this, null);
    String authUrl;
    try {
    authUrl = th.getAuthUrl();
    i.setData(Uri.parse(authUrl));
    startActivity(i);

    } catch (Exception e) {
    Toast.makeText(getApplicationContext(), “Error: ” + e.getMessage(),
    15000).show();
    e.printStackTrace();
    }
    }

    /**
    * Now generate an auth token from the pin, the user provided (obtained from
    * Twitter), store the pin and auth token and proceed to the TabWidget.
    *
    * @param v
    */
    @SuppressWarnings(“unused”)
    public void setPinButton(View v) {
    EditText pinField = (EditText) findViewById(R.id.pinText);
    if (pinField != null) {
    if (pinField.getText() != null
    && pinField.getText().toString() != null) {
    String pin = pinField.getText().toString();
    TwitterHelper th = new TwitterHelper(this, null); // pass a null
    // account,
    // which is
    // uninitialized

    try {
    Account acct = th.generateAccountWithOauth(pin);
    proceed(acct);

    } catch (Exception e) {
    Toast.makeText(getApplicationContext(),
    “Error: ” + e.getMessage(), 15000).show();
    e.printStackTrace();
    }
    }
    }
    }

    /**
    * Obtain a auth token the xAuth way by providing username and password and
    * then proceed to the TabWidget. Also works for identi.ca
    *
    * @param v
    * Source view
    */
    @SuppressWarnings(“unused”)
    public void loginXauth(View v) {
    EditText userText = (EditText) findViewById(R.id.login_username);
    String user = userText.getText().toString();
    EditText passwordText = (EditText) findViewById(R.id.login_password);
    String password = passwordText.getText().toString();
    Spinner spinner = (Spinner) findViewById(R.id.spinner1);
    String service = spinner.getSelectedItem().toString();

    try {
    new CreateAccountTask(this,user,password,service,true).execute().get();
    Log.i(“Login.xauth”,”Account created”);
    proceed();
    } catch (InterruptedException e) {
    e.printStackTrace(); // TODO: Customise this generated block
    } catch (ExecutionException e) {
    e.printStackTrace(); // TODO: Customise this generated block
    }
    // finish();

    /*

    TwitterHelper th = new TwitterHelper(this, null); // pass a null
    // account, which is
    // uninitialized
    try {
    Account account = th.generateAccountWithXauth(user, password, service, true);
    proceed(account);
    finish();

    } catch (Exception e) {
    e.printStackTrace(); // TODO: Customise this generated block
    Toast.makeText(this, “Login failed: ” + e.getMessage(),
    Toast.LENGTH_LONG).show();

    }
    */
    }

    private void proceed() {
    Intent i = new Intent().setClass(this, TabWidget.class);
    startActivity(i);
    finish();
    }

    /**
    * Call the TabWidget activity that does the work.
    *
    * @param account
    * Logged in account
    */
    private void proceed(Account account) {
    AccountHolder.getInstance().setAccount(account);
    Intent i = new Intent().setClass(this, TabWidget.class);
    startActivity(i);
    finish();
    }

    public void foo(View v) {
    Intent i = new Intent(this,TwitterLoginActivity.class);
    startActivity(i);
    }

    }

  33. willie willie

    import java.util.Scanner;
    import java.util.*;
    import java.lang.*;

    class Main
    {
    String s;
    Scanner sc=new Scanner(System.in);
    StringTokenizer stz;
    public void define()
    {
    System.out.println(“Enter the text”);
    s=sc.nextLine();
    stz=new StringTokenizer(s,” “);
    }
    public void display()
    {
    int i=stz.countTokens();
    int []freq=new int[i];
    String st[]=new String[50];
    int j=0;
    while(stz.hasMoreTokens())
    {
    st[j]=stz.nextToken().toString();
    freq[j++]=1;
    }
    for(int k=0;k<i;k++)
    {
    for(j=k+1;j<i;j++)
    { if((freq[k])!=0)
    freq[k]++;
    freq[j]–;
    }
    }
    for(int k=0;k<i;k++)
    {
    if((freq[k])!=0)
    {
    System.out.println(st[k]+":"+freq[k]);
    }
    }
    }

    public static void main (String[] args) throws java.lang.Exception
    {
    Main m=new Main();
    m.define();
    m.display();

    }
    }

  34. Jhay Jhay

    please someone help me please…
    Sample Output :
    Enter no. of rows [2-10] : 3
    Enter value for matrix[0][0] : 1
    Enter value for matrix[0][1] : 2
    Enter value for matrix[0][2] : 3
    Enter value for matrix[1][0] : 4
    Enter value for matrix[1][1] : 5
    Enter value for matrix[1][2] : 6
    Enter value for matrix[2][0] : 7
    Enter value for matrix[2][1] : 8
    Enter value for matrix[2][2] : 9
    Output:
    1 2 3 6
    4 5 6 15
    7 8 9 24
    12 15 18

    ==== my program have an error OutOfBound blah blah…..
    import java.io.*;
    public class MP2{
    public static void main(String [] a) throws IOException{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

    String str=””;
    int rowcol;
    int [][]save= new int [rowcol][rowcol];

    System.out.println(“Enter number of rows [2-10]:”);
    rowcol=Integer.parseInt(br.readLine());

    for( int row=0; row<rowcol; row++){
    for(int col=0; col<rowcol; col++){
    System.out.println("Enter a value for matix ["+row+"]"+"["+col+"]:");
    save[row][col]=Integer.parseInt(br.readLine());
    }
    }

    //this for loop is wrong; I just want to display the whatever the user inputs :(
    for(int n=0; n<save.length; n++) {
    for(int m=0; m<save[n].length; m++){

    System.out.print(save[n][m]);

    }
    }

    }
    }

  35. tanmoy jana tanmoy jana

    problem:
    java.lang.NumberFormatException: For input string: “”
    source code:

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package com.medicalportal.servlets;

    import com.medicalportal.classes.SQL;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    /**
    *
    * @author Tanmoy Jana
    */
    public class ProcessAdminEmployeeRegister extends HttpServlet {

    /**
    * Processes requests for both HTTP GET and POST methods.
    * @param request servlet request
    * @param response servlet response
    * @throws ServletException if a servlet-specific error occurs
    * @throws IOException if an I/O error occurs
    */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException{
    response.setContentType(“text/html;charset=UTF-8”);
    PrintWriter out = response.getWriter();
    try {
    SQL sql = new SQL();

    String[] values = new String[10];

    values[0] = new SQL().getId(“EMPLOYEE”);
    values[1] = request.getParameter(“select”);
    values[2] = request.getParameter(“textfield2”);
    values[3] = request.getParameter(“textfield3”);
    values[4] = request.getParameter(“textfield4”);
    values[5] = request.getParameter(“RadioGroup1”);
    values[6] = request.getParameter(“textfield5”);
    values[7] = request.getParameter(“textfield6”);
    values[8] = request.getParameter(“select2”);
    values[9] = request.getParameter(“textfield32”);

    String[] values1 = new String[7];
    values1[0] = values[2];
    values1[1] = request.getParameter(“textfield8”);
    values1[2] = “”;
    values1[3] = “”;
    values1[4] = request.getParameter(“textfield7”);
    values1[5] = “”;
    values1[6] = values[1];

    if(sql.insertData(“EMPLOYEE”, “?,?,?,?,?,?,?,?,?,?”, values) && sql.insertData(“ACCOUNT”, “?,?,?,?,?,?,?”, values1)){
    out.println(“successfully inserted”);
    }else{
    out.println(“Error”);
    }

    }catch(Exception ex) {
    out.println(ex.toString());

    } finally {
    out.close();
    }
    }

  36. ajay ajay

    public class solution1
    {
    pulic class student
    {public string fathers_name;
    public int rollno;
    public string name[20];
    int marks[5];
    int age;
    public void input()
    {
    Scanner a = new Scanner(System.in);
    System.out.println(“Enter name “);
    name=a.nextline();

    System.out.println(“Enter rollno “);
    rollno=a.nextInt();
    System.out.println(“enter fathers name”);
    fathers_name=a.nextline();
    System.out.println(“Enter marks “);
    marks[0]=a.nextInt();
    marks[1]=a.nextInt();
    marks[2]=a.nextInt();
    marks[3]=a.nextInt();
    marks[4]=a.nextInt();
    System.out.println(“Enter age”);
    age=a.nextInt();
    }

    public void disp(){
    System.out.println(“Name “+name);
    System.out.println(“rollno “+rollno);
    System.out.println<<("marks: "+marks[0]+" "+marks[1]" "+marks[2]+" "+marks[3]+ " "+marks[4] );
    System.out.println("Fathers name "+fathers_name);
    System.out.println<<"Age "<<age;
    }

    };

    public static void main(String args[])
    {
    student s=new student;
    s.input();
    s.display();
    }

    };

  37. Kriti Kriti

    class Position
    {
    public void main(int n[])
    {
    n[]=new int[100];
    double S=0.0;
    System.out.println(“Enter 100 elements”);
    for(int i=0;i<100;i++)
    {
    System.out.println(+n[i]);
    S=S+n[i];
    }
    double m;m=S/100;
    System.out.println("Mean="+m);
    int p=0;
    double d=n[0]-m;
    for(int y=1;yn[y]-m)
    {
    d=d;
    p=p;
    }
    else
    {
    d=n[y]-m;
    p=y;
    }
    }
    System.out.println(“Maximum deviation of mean is from”+p);
    }
    }

  38. ramesh ramesh

    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.BufferedReader;
    import java.io.PrintWriter;
    import java.io.IOException;

    public class ReadWriteTextFile {

    private static void doReadWriteTextFile() {

    try {

    String inputFileName = “README_InputFile.txt”;
    String outputFileName = “ReadWriteTextFile.out”;

    FileReader inputFileReader = new FileReader(inputFileName);
    FileWriter outputFileReader = new FileWriter(outputFileName);

    BufferedReader inputStream = new BufferedReader(inputFileReader);
    PrintWriter outputStream = new PrintWriter(outputFileReader);

    // Keep in mind that all of the above statements can be combined
    // into the following:
    //BufferedReader inputStream = new BufferedReader(new FileReader(“README_InputFile.txt”));
    //PrintWriter outputStream = new PrintWriter(new FileWriter(“ReadWriteTextFile.out”));

    outputStream.println(“+———- Testing output to a file ———-+”);
    outputStream.println();

    String inLine = null;

    while ((inLine = inputStream.readLine()) != null) {
    outputStream.println(inLine);
    }

    outputStream.println();
    outputStream.println(“+———- Testing output to a file ———-+”);

    outputStream.close();
    inputStream.close();

    } catch (IOException e) {

    System.out.println(“IOException:”);
    e.printStackTrace();

    }

    }
    public static void main(String[] args) {
    doReadWriteTextFile();
    }

    }

  39. Ankur Jain Ankur Jain

    package com.lara;
    import java.util.Scanner;
    public class F
    {
    public static void main(String[] args)
    {
    Scanner sc = new Scanner(System.in);
    System.out.println(“Enter Some-Thing”);
    String s1 = sc.next();
    int i = test(s1);
    System.out.println(i);
    }
    static int test(String s1)
    {int i = 0;
    try
    {
    i = Integer.parseInt(s1);
    return i;
    }
    catch (NumberFormatException ex)
    {
    return 0;
    }
    /*catch (ArithmeticException ex1)
    {
    System.out.println(7);
    System.out.println(ex1);
    System.out.println(8);
    }*/
    finally
    {
    return 1000;
    }
    System.out.println(1);
    }
    }

  40. Anusha//marachapu Anusha//marachapu

    could anyone give me a program on how an atm runs

  41. Anusha//marachapu Anusha//marachapu

    could anyone give me a program on how an atm runs?? please

  42. can any one give the source code to create one social network website……please

  43. Terry Terry

    public class BigDebt
    {
    public static void main(String[] arguments)
    {
    int debt = 59000000;
    debt = debt/1440;
    System.out.println(“A minute’s worth of debt is $” + debt);
    }
    }

  44. SUDIP SUDIP

    import java.io.*;
    public class Tourism
    {
    public static void main(String args[])throws IOException
    {
    int q1,q2,q3,ch,ch1,chq;
    String pr;
    BufferedReader x=new BufferedReader(new InputStreamReader(System.in));
    System.out.println(” WELCOME TO PROJECT OF GROUP D-PROJ10D”);
    System.out.println(“PROJECT TOPIC—–>>TOURISM MANAGEMENT”);
    System.out.println(“GROUP MEMBERS ARE”);
    System.out.println(“Chandreyee Ray”);
    System.out.println(“Ditipriya Brahma”);
    System.out.println(“Surabhi Mitra “);
    System.out.println(“Pragya Ray”);
    System.out.println(“Anandi Bandyopadhay “);
    System.out.println(“please maximize your terminal window”);
    System.out.println(“PLEASE PRESS ENTER KEY(<—|)TO CONTINUE");
    pr=x.readLine();
    for(i=1;i<=28;i++)
    {
    System.out.println();
    }
    q1=1;
    while(q1=1)
    {
    System.out.println("THE SITE LOCATIONS IN OUR TOUR PACKAGE ARE");
    System.out.println("1.MOUNTAINS");
    System.out.println("2.SEA BEACHES");
    System.out.println("3.PILGRIMAGES");
    System.out.println("4.FORESTS");
    System.out.println("5.HERITAGE SPOTS");
    System.out.println("PLEASE ENTER THE CORRESPONDING SERIAL NUMBER OF
    THE SITE LOCATION OF YOUR CHOICE");
    q2=1;
    while(q2==1)
    {
    ch=Integer.parseInt(x.readLine());
    switch(ch)
    {
    case 1: q2=0;
    String mount[]={"0.KULLU","1.ARAKU VALLEY","2.DARJEELING "};
    System.out.println("THE PLACES WE OFFER IN OUR THIS PACKAGE ARE");
    for(i=0;i<3;i++)
    {
    System.out.println(mount[i]);
    }
    break;
    case 2:
    q2=0;
    String beach[]={"0.MARINA SEA BEACH,CHENNAI","1.GOA","2.DIGHA "};
    System.out.println("THE PLACES WE OFFER IN OUR THIS PACKAGE ARE");
    for(i=0;i<3;i++)
    {
    System.out.println(beach[i]);
    }
    break;
    case 3: q2=0;
    String pilgrim[]={"0.KANYAKUMARI","1.TIRUPATI","2.PURI "};
    System.out.println("THE PLACES WE OFFER IN OUR THIS PACKAGE ARE");
    for(i=0;i<3;i++)
    {
    System.out.println(pilgrim[i]);
    }
    break;
    case 4:
    q2=0;
    String forest[]={"0.SUNDERBANS","1.KAZIRANGA","2.JALDAPARA-DOOARS"};
    System.out.println("THE PLACES WE OFFER IN OUR THIS PACKAGE ARE");
    for(i=0;i<3;i++)
    {
    System.out.println(forest[i]);
    }
    break;
    case 5:
    q2=0;
    String heritage[]={"0.TAJ MAHAL","1.RED FORT","2.MURSHIDABAD"};
    System.out.println("THE PLACES WE OFFER IN OUR THIS PACKAGE ARE");
    for(i=0;iROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO KULLU MANALI AIRPORT.OR TAKE ANY TRAIN REACHING
    “+”
    CHANDIGARH RAILSTATION.OR REACH CHANDIGARH BY NH1.FROM THERE TO
    REACH KULLU TAKE NH24″);
    System.out.println();

    System.out.println(“KULLU ATRACTIONS—–>”+”
    (A)RAGHUNATH
    TEMPLE”+”
    (B)RAISON”+”
    (C)BASHESHWAR MAHADEV TEMPLE”);
    System.out.println();
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)*****APPLE VALLEY
    RESORT-Rs10050″+”
    (B)***SNOW PRINCESS HOTEL-Rs5060″+”
    (C)SANDHYA
    HERITAGE HOTEL-Rs3020″);
    System.out.println();
    break;
    case 2:
    q3=0;
    System.out.println(” ARAKU VALLEY “);
    System.out.println();
    System.out.println(“ON SEASON-mar to june”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 1084Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO Vishakhapatnam AIRPORT.OR TAKE ANY TRAIN REACHING
    “+”Vishakhapatnam RAILSTATION. It takes 12 hrs and 29 MINS to
    REACH.”);
    System.out.println();
    System.out.println(“ARAKU VALLEY ATRACTIONS—–>”+”
    (A)BORRA
    CAVES”+”
    (B)BHEEMUNIPATNAM BEACH”+”
    (C)ANANTGIRI HILLS”);
    System.out.println();
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)*****JUNGLE BELL
    NATURE CAMP-Rs9050″+”
    (B)***MAYURI HILL
    RESORT-Rs3090″+”
    *(C)KRISHNATAR COMFORTS-Rs1090″);
    break;
    case 3:
    q3=0;
    System.out.println();
    System.out.println(” DARJEELING “);
    System.out.println(“ON SEASON-mar to June”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 834Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO BAGDOGRA AIRPORT.OR TAKE ANY TRAIN REACHING “+”
    SILIGURI
    JUNCTION.OR GO TO SILIGURI BY ROAD.FROM THERE TAKE ANY SMALL VEHICLE
    TO REACH DARJEELING WITHIN 4 HRS”);
    System.out.println();
    System.out.println(“DARJEELING ATRACTIONS—–>”+”
    (A)KANCHENJUNGA
    MOUNTAINS”+”
    (B)PADMA NAIDU HIMALAYAN ZOOLOGICAL PARK”+”
    (C)TIGER
    HILL”);

    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)****MOHIT
    HOTELS-Rs6050″+”
    (B)**HOTEL WINDAMERE-Rs4599″+”
    (C)*HOTEL
    LUNAR-Rs2050″);
    break;
    default:
    q3==1;
    System.out.println(“INVALID CHOICE.PLEASE RE-ENTER”);
    }}
    if(ch==2)
    {
    q3=1;
    while(q3==1)
    {
    ch1=Integer.parseInt(x.readLine());
    switch(ch1)
    {
    case 1:
    q3=0;
    System.out.println(” MARINA BEACH”);
    System.out.println(“ON SEASON-oct & nov”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 1725Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO KULLU MANALI AIRPORT.OR TAKE ANY TRAIN REACHING
    “+”
    CHANDIGARH RAILSTATION.OR REACH CHANDIGARH BY NH1.FROM THERE TO
    REACH KULLU TAKE NH24″);
    System.out.println();

    System.out.println(“KULLU ATRACTIONS—–>”+”
    (A)RAGHUNATH
    TEMPLE”+”
    (B)RAISON”+”
    (C)BASHESHWAR MAHADEV TEMPLE”);
    System.out.println();
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)*****APPLE VALLEY
    RESORT-Rs10050″+”
    (B)***SNOW PRINCESS HOTEL-Rs5060″+”
    (C)SANDHYA
    HERITAGE HOTEL-Rs3020″);
    System.out.println();
    break;
    case 2:
    q3=0;
    System.out.println(” GOA “);
    System.out.println();
    System.out.println(“ON SEASON-mar to june”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 1084Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO Vishakhapatnam AIRPORT.OR TAKE ANY TRAIN REACHING
    “+”Vishakhapatnam RAILSTATION. It takes 12 hrs and 29 MINS to
    REACH.”);
    System.out.println();
    System.out.println(“ARAKU VALLEY ATRACTIONS—–>”+”
    (A)BORRA
    CAVES”+”
    (B)BHEEMUNIPATNAM BEACH”+”
    (C)ANANTGIRI HILLS”);
    System.out.println();
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)*****JUNGLE BELL
    NATURE CAMP-Rs9050″+”
    (B)***MAYURI HILL
    RESORT-Rs3090″+”
    *(C)KRISHNATAR COMFORTS-Rs1090″);
    break;
    case 3:
    q3=0;
    System.out.println();
    System.out.println(” DIGHA “);
    System.out.println(“ON SEASON-mar to June”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 834Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO BAGDOGRA AIRPORT.OR TAKE ANY TRAIN REACHING “+”
    SILIGURI
    JUNCTION.OR GO TO SILIGURI BY ROAD.FROM THERE TAKE ANY SMALL VEHICLE
    TO REACH DARJEELING WITHIN 4 HRS”);
    System.out.println();
    System.out.println(“DARJEELING ATRACTIONS—–>”+”
    (A)KANCHENJUNGA
    MOUNTAINS”+”
    (B)PADMA NAIDU HIMALAYAN ZOOLOGICAL PARK”+”
    (C)TIGER
    HILL”);
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)****MOHIT
    HOTELS-Rs6050″+”
    (B)**HOTEL WINDAMERE-Rs4599″+”
    (C)*HOTEL
    LUNAR-Rs2050″);
    break;
    default:
    q3==1;
    System.out.println(“INVALID CHOICE.PLEASE RE-ENTER”);
    }}
    if(ch==3)
    {
    q3=1;
    while(q3==1)
    {
    ch1=Integer.parseInt(x.readLine());
    switch(ch1)
    {
    case 1:
    q3=0;
    System.out.println(” KANYAKUMARI “);
    System.out.println(“ON SEASON-oct & nov”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 1725Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO KULLU MANALI AIRPORT.OR TAKE ANY TRAIN REACHING
    “+”
    CHANDIGARH RAILSTATION.OR REACH CHANDIGARH BY NH1.FROM THERE TO
    REACH KULLU TAKE NH24″);
    System.out.println();

    System.out.println(“KULLU ATRACTIONS—–>”+”
    (A)RAGHUNATH
    TEMPLE”+”
    (B)RAISON”+”
    (C)BASHESHWAR MAHADEV TEMPLE”);
    System.out.println();
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)*****APPLE VALLEY
    RESORT-Rs10050″+”
    (B)***SNOW PRINCESS HOTEL-Rs5060″+”
    (C)SANDHYA
    HERITAGE HOTEL-Rs3020″);
    System.out.println();
    break;
    case 2:
    q3=0;
    System.out.println(” TIRUPATI “);
    System.out.println();
    System.out.println(“ON SEASON-mar to june”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 1084Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO Vishakhapatnam AIRPORT.OR TAKE ANY TRAIN REACHING
    “+”Vishakhapatnam RAILSTATION. It takes 12 hrs and 29 MINS to
    REACH.”);
    System.out.println();
    System.out.println(“ARAKU VALLEY ATRACTIONS—–>”+”
    (A)BORRA
    CAVES”+”
    (B)BHEEMUNIPATNAM BEACH”+”
    (C)ANANTGIRI HILLS”);
    System.out.println();
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)*****JUNGLE BELL
    NATURE CAMP-Rs9050″+”
    (B)***MAYURI HILL
    RESORT-Rs3090″+”
    *(C)KRISHNATAR COMFORTS-Rs1090″);
    break;
    case 3:
    q3=0;
    System.out.println();
    System.out.println(” PURI “);
    System.out.println(“ON SEASON-mar to June”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 834Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO BAGDOGRA AIRPORT.OR TAKE ANY TRAIN REACHING “+”
    SILIGURI
    JUNCTION.OR GO TO SILIGURI BY ROAD.FROM THERE TAKE ANY SMALL VEHICLE
    TO REACH DARJEELING WITHIN 4 HRS”);
    System.out.println();
    System.out.println(“DARJEELING ATRACTIONS—–>”+”
    (A)KANCHENJUNGA
    MOUNTAINS”+”
    (B)PADMA NAIDU HIMALAYAN ZOOLOGICAL PARK”+”
    (C)TIGER
    HILL”);

    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)****MOHIT
    HOTELS-Rs6050″+”
    (B)**HOTEL WINDAMERE-Rs4599″+”
    (C)*HOTEL
    LUNAR-Rs2050″);
    break;
    default:
    q3==1;
    System.out.println(“INVALID CHOICE.PLEASE RE-ENTER”);
    }}
    if(ch==1)
    {
    q3=1;
    while(q3==1)
    {
    ch1=Integer.parseInt(x.readLine());
    switch(ch1)
    {
    case 1:
    q3=0;
    System.out.println(” SUNDERBANS “);
    System.out.println(“ON SEASON-oct & nov”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 1725Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO KULLU MANALI AIRPORT.OR TAKE ANY TRAIN REACHING
    “+”
    CHANDIGARH RAILSTATION.OR REACH CHANDIGARH BY NH1.FROM THERE TO
    REACH KULLU TAKE NH24″);
    System.out.println();

    System.out.println(“KULLU ATRACTIONS—–>”+”
    (A)RAGHUNATH
    TEMPLE”+”
    (B)RAISON”+”
    (C)BASHESHWAR MAHADEV TEMPLE”);
    System.out.println();
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)*****APPLE VALLEY
    RESORT-Rs10050″+”
    (B)***SNOW PRINCESS HOTEL-Rs5060″+”
    (C)SANDHYA
    HERITAGE HOTEL-Rs3020″);
    System.out.println();
    break;
    case 2:
    q3=0;
    System.out.println(” KAZIRANGA “);
    System.out.println();
    System.out.println(“ON SEASON-mar to june”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 1084Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO Vishakhapatnam AIRPORT.OR TAKE ANY TRAIN REACHING
    “+”Vishakhapatnam RAILSTATION. It takes 12 hrs and 29 MINS to
    REACH.”);
    System.out.println();
    System.out.println(“ARAKU VALLEY ATRACTIONS—–>”+”
    (A)BORRA
    CAVES”+”
    (B)BHEEMUNIPATNAM BEACH”+”
    (C)ANANTGIRI HILLS”);
    System.out.println();
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)*****JUNGLE BELL
    NATURE CAMP-Rs9050″+”
    (B)***MAYURI HILL
    RESORT-Rs3090″+”
    *(C)KRISHNATAR COMFORTS-Rs1090″);
    break;
    case 3:
    q3=0;
    System.out.println();
    System.out.println(” JALDAPARA “);
    System.out.println(“ON SEASON-mar to June”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 834Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO BAGDOGRA AIRPORT.OR TAKE ANY TRAIN REACHING “+”
    SILIGURI
    JUNCTION.OR GO TO SILIGURI BY ROAD.FROM THERE TAKE ANY SMALL VEHICLE
    TO REACH DARJEELING WITHIN 4 HRS”);
    System.out.println();
    System.out.println(“DARJEELING ATRACTIONS—–>”+”
    (A)KANCHENJUNGA
    MOUNTAINS”+”
    (B)PADMA NAIDU HIMALAYAN ZOOLOGICAL PARK”+”
    (C)TIGER
    HILL”);

    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)****MOHIT
    HOTELS-Rs6050″+”
    (B)**HOTEL WINDAMERE-Rs4599″+”
    (C)*HOTEL
    LUNAR-Rs2050″);
    break;
    default:
    q3==1;
    System.out.println(“INVALID CHOICE.PLEASE RE-ENTER”);
    }}
    if(ch==1)
    {
    q3=1;
    while(q3==1)
    {
    ch1=Integer.parseInt(x.readLine());
    switch(ch1)
    {
    case 1:
    q3=0;
    System.out.println(” TAJ MAHAL “);
    System.out.println(“ON SEASON-oct & nov”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 1725Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO KULLU MANALI AIRPORT.OR TAKE ANY TRAIN REACHING
    “+”
    CHANDIGARH RAILSTATION.OR REACH CHANDIGARH BY NH1.FROM THERE TO
    REACH KULLU TAKE NH24″);
    System.out.println();

    System.out.println(“KULLU ATRACTIONS—–>”+”
    (A)RAGHUNATH
    TEMPLE”+”
    (B)RAISON”+”
    (C)BASHESHWAR MAHADEV TEMPLE”);
    System.out.println();
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)*****APPLE VALLEY
    RESORT-Rs10050″+”
    (B)***SNOW PRINCESS HOTEL-Rs5060″+”
    (C)SANDHYA
    HERITAGE HOTEL-Rs3020″);
    System.out.println();
    break;
    case 2:
    q3=0;
    System.out.println(” RED FORT “);
    System.out.println();
    System.out.println(“ON SEASON-mar to june”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 1084Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO Vishakhapatnam AIRPORT.OR TAKE ANY TRAIN REACHING
    “+”Vishakhapatnam RAILSTATION. It takes 12 hrs and 29 MINS to
    REACH.”);
    System.out.println();
    System.out.println(“ARAKU VALLEY ATRACTIONS—–>”+”
    (A)BORRA
    CAVES”+”
    (B)BHEEMUNIPATNAM BEACH”+”
    (C)ANANTGIRI HILLS”);
    System.out.println();
    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)*****JUNGLE BELL
    NATURE CAMP-Rs9050″+”
    (B)***MAYURI HILL
    RESORT-Rs3090″+”
    *(C)KRISHNATAR COMFORTS-Rs1090″);
    break;
    case 3:
    q3=0;
    System.out.println();
    System.out.println(” MURSHIDABAD “);
    System.out.println(“ON SEASON-mar to June”);
    System.out.println();
    System.out.println(“DISTANCE FROM BERHAMPORE IS 834Kms BY ROAD”);
    System.out.println();
    System.out.println(“MEANS OF TRANSPORT—>ROAD,RAIL,AIRWAY”);
    System.out.println();
    System.out.println(“ROUTE OF TRANSPORT—>FROM BERHAMPORE TO HOWRAH BY
    RAIL,ROAD THEN EITHER TAKE”+”
    FLIGHT FROM INDIRA GANDHI NATIONAL
    AIRPORT TO BAGDOGRA AIRPORT.OR TAKE ANY TRAIN REACHING “+”
    SILIGURI
    JUNCTION.OR GO TO SILIGURI BY ROAD.FROM THERE TAKE ANY SMALL VEHICLE
    TO REACH DARJEELING WITHIN 4 HRS”);
    System.out.println();
    System.out.println(“DARJEELING ATRACTIONS—–>”+”
    (A)KANCHENJUNGA
    MOUNTAINS”+”
    (B)PADMA NAIDU HIMALAYAN ZOOLOGICAL PARK”+”
    (C)TIGER
    HILL”);

    System.out.println(“HOTELS AVAILABLE—–>”+”
    (A)****MOHIT
    HOTELS-Rs6050″+”
    (B)**HOTEL WINDAMERE-Rs4599″+”
    (C)*HOTEL
    LUNAR-Rs2050″);
    break;
    default:
    q3==1;
    System.out.println(“INVALID CHOICE.PLEASE RE-ENTER”);
    }}
    }
    System.out.println(“PLEASE PRESS ENTER KEY(<—|)TO CONTINUE");
    pr2=x.readLine();
    for(i=1;i<=40;i++);
    {
    System.out.println();
    }System.out.println(" THANK YOU!!!");
    System.out.println(" HOPE YOU ENJOYED OUR GUIDANCE TO SPEND
    YOUR HOLIDAYS AMAZINGLY");
    System.out.println(" WISH YOU A HAPPY JOURNEY");
    System.out.println(" HOPE YOU WILL VISIT US AGAIN.");
    System.out.println(" BYE!!!!!!!!");
    System.out.println("PLEASE PRESS ENTER KEY(<—|)TO CONTINUE");
    pr3=x.readLine();
    for(i=1;i<=30000;i++);
    {
    System.out.println();
    }
    System.out.println("WE ALL ARE WHOLEHEARTEDLY AND GRATEFULLY
    ACKNOWLEDGED TO OUR "+"
    COMPUTER TEACHER SRI.ASHISH ROY CHOWDHURY FOR
    GIVING US SUCH A WONDERFUL TOPIC TO WORK UPON AND"+"
    HELPING US
    WHENEVER POSSIBLE TO COMPLETE THIS PROJECT ON TIME AND SUBMIT IT ON
    THE"+"
    STIPULATED TIME");
    System.out.println("PLEASE PRESS “1” TO TRY FOR ANOTHER TIME OR”0” TO EXIT);
    chq=Integer.parseInt(x.readLine());
    q1=chq;
    }
    System.exit(0);
    }}

  45. lynda lynda

    ERROR WITH IF ELSE STATEMENT
    public boolean isValidRoomNo(String roomNo, String floorNo)
    {
    int room = roomNo.length();
    if (room == 3){

    ifInteger.valueOf(floorNo >= 0 && floorNo 0 && roomNo <=12);
    {
    return true;
    }

    else {
    return false;
    }
    }
    else {
    return false;
    }

  46. sivaramana sivaramana

    Hello everyone..

    I have found a nice website for online java compiler and executor and acts like an IDE for standalone program java. And I have found useful materials too. find it below…

    http://www.javalaunch.com

    Hope you enjoy this site…

  47. hana hana

    Write a function that returns an array of all elements of the natural numbers in order from first to last print.

    plz answer it with java and instantly

    • Raghav Raghav

      There are infinity natural numbers, but this will print the first n;

      import java.lang.*;
      public class PrintNaturals {
      const int n = 10; //substitute 10 for anything!
      public static void main(String[] args)
      {
      int[n] naturals; //array of natural numbers
      for (int i = 0; i < n; i ++)
      {
      naturals[i] = i + 1;
      }
      //Now you have an array of natural numbers, now let's print it
      for (int i = 0; i < n; i ++)
      {
      System.out.print((String)naturals[i]);
      }
      }
      }

  48. Try JDoodle.com, here you can compile, run, save and share java programs online.

Leave a Reply