programme:-write it in notepad
import java.util.*;
public class sum
{
public static void main(String args[])
{
int x,y,z;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the value of x and y");
x=sc.nextInt();
y=sc.nextInt();
z=x+y;
{
System.out.println("sum"+(z));
}
}
}
To run this first save it by sum.java
1) javac sum.java (press enter)
2) java sum (press enter)
Type this lines 1 and 2 in cmd
import java.util.*;
public class sum
{
public static void main(String args[])
{
int x,y,z;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the value of x and y");
x=sc.nextInt();
y=sc.nextInt();
z=x+y;
{
System.out.println("sum"+(z));
}
}
}
To run this first save it by sum.java
1) javac sum.java (press enter)
2) java sum (press enter)
Type this lines 1 and 2 in cmd
No comments:
Post a Comment