8. Write a program in java to input two integer number from keyboard calculate and print sum of two integer number?

import java.io.DataInputStream; class Calculate {                 public static void main(String args[])                 {                                 DataInputStream in=new DataInputStream(System.in);                                 int a=0,b=0,c=0;                                 try                                 {                                                 System.out.println("Enter A First Number : ");                                                 a=Integer.parseInt(in.readLine());                                                 System.out.println("Enter A Second Number : ");                                                 b=Integer.parseInt(in.readLine());                                 }                                 catch(Exception e)                                 {                                 }                                 c=a+b;                                 System.out.println("Sum... Continue Reading →

Advertisements

Data type: –

Data type: - Every variable in a java has a data type. Data types specify the size and type of values that can be stored. Java language is rich in its data type. The variety of data types available allow the programmer to select the type appropriate to needs of application. Basic data type of... Continue Reading →

7. An example for read data from keyboard is as fallows –

import java.io.DataInputStream; class Reading {                 public static void main(String args[])                 {                                 DataInputStream in=new DataInputStream(System.in);                                 int a=0;                                 float b=0.0f;                                 try                                 {                                                 System.out.println("Enter An Integer : ");                                                 a=Integer.parseInt(in.readLine());                                                 System.out.println("Enter A Float : ");                                                 b=Float.valueOf(in.readLine()).floatValue();                                 }                                 catch(Exception e)                                 {                                 }                                 System.out.println("Integer =... Continue Reading →

Variable: –

Variable: - A variable is an identifier that denotes a storage location used to store data value. Unlike constants that remain unchanged during the execution of program, a variable may take different values at different times during the execution of program. A variable name can be chosen by the program in a meaningful way so... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: