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

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /