Prerequisite
Java
To develop and run any java program you need to install Java in your system. You can download the latest version of Java for Windows/ Mac/ Linux/ Solaris from here. For more detailed steps, please visit this page.
IntelliJ IDE
After downloading Java, you need to download an IDE. I personally prefer IntelliJ IDEA because it provides to its users over alternative solutions such as text editors or open-source IDEs: Higher developer productivity, enhanced developer focus, reduced technical debt, increased testing and debugging productivity and improved testing plans. To get access to IntelliJ IDEA, go to this page and download its community version, run the set up and finish installing it.
Code
Explanation
Scanner is a class in java.util package used for obtaining the input of the primitive types like int, double, etc. and strings from the console.
Running the code
![](https://compilationerrors.wordpress.com/wp-content/uploads/2020/04/image.png?w=638)
Feel free to post queries.
Thanks a lot.
The coding over here is easy and simple. Helped a lot on my school project . It would be a great help if you can teach stacks and arrays too .
LikeLike