Input Output Statements

System.out.println:-  It is an output statement to print the strings or variables on output device.
Syntax: System.out.println(“String”/Variable);

Scanner:-By using this class we can read the values from the input device. This class belongs to java.util package.
Syntax: Scanner object=new Scanner(System.in);
Methods:
nextInt();
nextDouble();
nextLine();
nextByte();

SAMPLE PROGRAM TO SAY HELLO

class Sample
{
public static void main(String args[])
{
System.out.println("Welcome to java world");
}
}

PROGRAM TO FIND THE CENTIGRADE TO FORENHEAT.

import java.util.Scanner;
class Degree
{
public static void main(String args[])
{
int c;
double f;
Scanner read=new Scanner(System.in);
System.out.println(“Enter C value”);
c=read.nextInt();
f=(c-32)*5/9;
System.out.println("Foreighn heat Value"+f);
}
}

PROGRAM TO FIND THE SIMPLE INTEREST.

import java.utl.Scanner;
class Rest
{
public static void main(String args[])
{
int p,t,r;
Scanner read=new Scanner(System.in);
System.out.println(“Enter p,t,r values”);
p=read.nextInt()  ;
t= read.nextInt()  ;
r= read.nextInt()  ;
double i;
i=(p*n*r)/100;
System.out.println("S.I: "+i);
}
}

 

 

For
Online Classes

Contact Us: 9885348743