freetimestudys@gmail.com          +91-7097633380
  Login Here                        

display a message

class msg
{
public static void main(String args[])
{
System.out.println("Welcome”);
}
}

intput and output

Welcome

add two numbers

import java.io.*;
class clsadd
{
public static void main(String args[])throws IOException
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
int a,b,c;
a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
c=a+b;
System.out.println("The Sum is "+c);}}

intput and output

10
20
The Sum is 30

arithmetic operations

import java.io.*;
class clsarith
{
public static void main(String args[])throws IOException
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
float a,b,c,d,e,f;
System.out.println("Enter the numbers:");
a=Float.parseFloat(br.readLine());
b=Float.parseFloat(br.readLine());
c=a+b;
d=a-b;
e=a*b;
f=a/b;
System.out.println(a + " + " + b + " = " + c);
System.out.println(a + " - " + b + " = " + d);
System.out.println(a + " * " + b + " = " + e);
System.out.println(a + " / " + b + " = " + f);
}
}

intput and output

Enter the numbers:
10
5
10.0 + 5.0 = 15.0
10.0 - 5.0 = 5.0
10.0 * 5.0 = 50.0
10.0 / 5.0 = 2.0