Computer Science, asked by jhansijeyakumar12, 1 year ago

give a sample program in java​

Answers

Answered by jaiveer1977
0

Answer:

We can write a simple hello java program easily after installing the JDK. To create a simple java program, you need to create a class that contains the main method.

We can write a simple hello java program easily after installing the JDK. To create a simple java program, you need to create a class that contains the main method....

We can write a simple hello java program easily after installing the JDK. To create a simple java program, you need to create a class that contains the main method....Creating Hello World Example

  1. class Simple{
  2. public static void main(String args[]){
  3. System. out. println("Hello Java");
  4. }
  5. }

Answered by Anonymous
1

TO FIND THE SUM OF TWO NUMBERS:

import java.io.*;

public class add

{

public static void main(String[]args)throws IOException

{

int a, b, c;

InputStreamReader read=new InputStreamReader(System.in);

BufferedReader in=new BufferedReader(read);

System.out.println("Enter the values of a and b:");

a=Integer.parseInt(in.readLine());

b=Integer.parseInt(in.readLine());

c=a+b;

System.out.println("The value of c is"+c);

}

}

TO FIND THE DIFFERENCE OF TWO NUMBERS:

import java.io.*;

public class difference

{

public static void main(String[]args)throws IOException

{

int a, b, c;

InputStreamReader read=new InputStreamReader(System.in);

BufferedReader in=new BufferedReader(read);

System.out.println("Enter the values of a and b:");

a=Integer.parseInt(in.readLine());

b=Integer.parseInt(in.readLine());

c=a-b;

System.out.println("The value of c is"+c);

}

}

Similar questions