WANT TO LEARN JAVA
Then follow this article
1:- First let's learn what is java?
So java is an object-oriented programming language that encapsulates many features of C++.
Originally java was designed to execute applets, downloaded while web browsing.
2:- Some basic features of java.
java is an object-oriented programming language.
3: java package contain several classes and each class contains different functions.
to know more about JDK (java development kit )check the link.
4: Before making a program, first we need to download JDK file click the link to download
JDK form its official page (link ) or you can google "download JDK for oracles ", you can download from their also.
5:- After installing JDK in your pc/laptop, you have to install an IDE you can use blue j or IntelliJ IDE. I will prefer you to download IntelliJ.
To download IDE click on the first link to download blue and second link to download IntelliJ.
And remember that you have to install JDK first the install IDE.
Now let's make a simple java program
The first program is as follows:-
// This is the program to add two numbers and to multiply to numbers.
(we will use // symbol to comment out a line in java programming, means java will not execute the line written after the double slash(//)).
Let's start
public class calculate
{
public static void main (String args[])
{
int add=0 ,product=0, sub=0,a=22,b=51;
// now here a &b are the two variables in which we store values
add=a+b;
sub=a-b;
product=a*b;
System.out.println("THE SUM OF TE GIVEN NUMBER IS="+add);
System.out.println("The difference of the given two number is ="+sub);
System.out.println("The product of the two number is ="+product);
}
}
--------------------------------------------------------------------------------------------------------------------------
The output of the given program is
THE SUM OF TE GIVEN NUMBER IS=73
The difference between the given two number is =-29
The product of the two number is =1122
You can use any variable you want.
and you can assign any number within that variable.
So, next, we will learn how to take user input from the keyboard.
Date July 6, 2020.
Today we will learn how to take input from the user
so to take input from user in java we use special class there are two method
1: through "util " class
let's see a simple program to take input from the user through the util package. A simple calculator to do addition, multiplication, subtraction, and division.
import java.util.*;
public class practice
{
public static void main (String args[])
{
Scanner in=newS canner(System.in);
double a,b,add=0,sub=0,div=0,product=0;
System.out.println("enter the first number ");
a=in.nextDouble();
System.out.println("enter the second number ");
b=in.nextDouble();
add=a+b;
sub=a-b;
div=a/b;
product=a*b;
System.out.println("The addition of the given number is="+add);
System.out.println("The subtraction of the given number is = "+sub);
System.out.println("The product of the given number is ="+product);
System.out.println("The division of the given number is ="+div);
}
}
"OUTPUT OF THE PROGRAM"
enter the first number
54
enter the second number
26
The addition of the given number is=80.0
The subtraction of the given number is = 28.0
The product of the given number is =1404.0
The division of the given number is =2.076923076923077
--------------------------------------------------------------------------------------------------------------------------
NEXT METHOD IS
THROUGH STREAM CLASS
Let's make ti same program through stream class.
import java.io.*;
public class practice
{
public static void main (String args[])throws IOException
{
InputStreamReader read =new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
double a,b,add=0,sub=0,div=0,product=0;
System.out.println("enter the first number ");
a=Double.parseDouble(in.readLine());
System.out.println("enter the second number ");
b=Double.parseDouble(in.readLine());
add=a+b;
sub=a-b;
div=a/b;
product=a*b;
System.out.println("The addition of the given number is="+add);
System.out.println("The subtraction of the given number is = "+sub);
System.out.println("The product of the given number is ="+product);
System.out.println("The division of the given number is ="+div);
}
}
the output of this program is
enter the first number
25
enter the second number
25
The addition of the given number is=50.0
The subtraction of the given number is = 0.0
The product of the given number is =625.0
The division of the given number is =1.0
_________________________________________________________________________________