10. Write a program in java to input ten integer number, calculate and print sum of all input numbers?

import java.io.DataInputStream; class Sum {                 public static void main(String args[])                 {                                 DataInputStream in=new DataInputStream(System.in);                                 int s=0,j=0,c=0;                                 try                                 {                                                 System.out.println("Enter 10 Integer Number : ");                                                 for(c=0;c<10;c++)                                                 {                                                                 j=Integer.parseInt(in.readLine());                                                                 s+=j;                                                 }                                 }                                 catch(Exception e) {}                                 System.out.println("Sum = "+s);                 } }

Advertisements

Scope of variable: –

Scope of variable: - Java variables are actually classified into three kinds. They are instance variable, class variable and local variable. Instance variable are created when the objects are initialized and there for they are associated with the object. They tech different values for each object. Class variables, on the other hand, are global to... Continue Reading →

9. Write a program in java to input three integer number from keyboard. Find and print a largest integer out of three input numbers?

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

Declaration of variable: –

Declaration of variable: - In java, variables are the names of storage location. After designing suitable variable name, we must declare them to the compiler. declaration does three things. (1) It tells the compiler what the variable name (2) It specifies what type of data the variable will hold. (3) The place of declaration decides... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: