Lift Operation – Program Development in Java Interesting !!!

import java.awt.geom.*;

public class elevator

    static int floor;

    public static void main(String args[])

        floor = (int) (Math.random() * 10 + 1);

        System.out.println("The elevator is now on floor " +floor);
        System.out.print("Which floor are you at now (0-10) where 0 = basement: ");
        int current_floor = Keyboard.readInt();

        if(floor == current_floor)
            System.out.println("Enter the elevator");

        System.out.println("To which floor would you want to go (0-10) where 0 = basement");
        int target_floor = Keyboard.readInt();


    public static void MoveElevator(int target_floor)
        int direction;
        if( target_floor > floor )
            System.out.println("The elevator is on it's way up...");
            direction = 1;
            System.out.println("The elevator is on it's way down...");
            direction = -1;

        while(target_floor != floor)
            floor += direction;

        System.out.println("The elevator has arrived");

About ashokabhat

I am a C,C ,JAVA,Adobe Flex,.NET Programmer Currently working as a Software Developer
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s