give a sample program in java
Answers
Answered by
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
- class Simple{
- public static void main(String args[]){
- System. out. println("Hello Java");
- }
- }
Answered by
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
Math,
5 months ago
Biology,
10 months ago
Physics,
10 months ago
Physics,
1 year ago
Social Sciences,
1 year ago