Programming Tutorials

Input and output in java

By: aathishankaran in Java Tutorials on 2007-02-01  

In the examples the keyword display was used for displaying the results of programs. The keyword display can be used for displaying constants as well as variables.

Example:

display Salary;

This displays the value stored in the numeric variable Salary on the screen

display "Manila";

This displays the string "Manila" on the screen

The keywords accept is used to obtain values from the user through the input device (Keyboard).

Example:

accept Salary;

This causes the program to wait for the user to type numeric value. The numeric value entered by the user will be stored in the variable Salary.

The following program accepts a name from the user and displays the same.

NAME_DISPLAY
{
char Name;
display "Enter Name:";
accept Name;
display "Hello";
display Name;
}

If the name is typed as "Robinson", it will display:

Hello Robinson

On the screen






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Java )

Latest Articles (in Java)