 Hello friends, I'm Sanjay Gupta. In this video, I'm going to demonstrate you how you can implement simple calculator in Java. So for implementation of calculator in Java, first we have to import scanner class that is available in util package. This scanner class is required to read input from user. Then I'm going to define a user defined class whose name is Kelsey. Inside this class, I'm going to define main method. Inside this main method, logic for calculator for performing addition, subtraction, multiplication and division will be implemented. So I am declaring three variables and one and two and three. Now I'm going to create instance of scanner class. I'm passing system.in as constructor. The system.in is responsible for deciding input location. So our input location is the console. Now with the help of this system.out.print talent, the message enter first number will be displayed on output screen. To read that number, this input.nextint statement will be executed. So next int is a predefined method which is available in scanner class. Now to read second number, I'm pasting these statements and modifying them. So this way, two numbers will be provided by the user. First will be stored in N1. Second will be stored inside N2. Now I have to display possible operations to the user so that user can enter a particular choice. Again, I am using system.out.print talent choices are here we have total four choices. First is addition. Second is subtraction. Third one is multiplication. Fourth one is division. Again, a message which will say enter your choice. So here user will be entering a particular choice. So I'm going to store that choice into ch variable. So ch equals to input.nextint. So choice will be available inside ch variable. Now I'm going to apply switch statement to check what choice has been entered by the user. Now inside this switch, I'm going to implement various cases. So if user enters one, this case one will be executed. So it will calculate addition and through this system.out.print talent. I can print addition equals to N3 and then break. Break is required if you want to execute a particular case. After implementation of case one, I can copy pasted three times. So this will be case two, here subtraction will be performed. Then case three, multiplication, then case four, division. So this way total four cases are implemented at last default. If user enters a particular choice other than one, two, three, four, then default will be executed automatically. So here we can print the message you have entered wrong choice. So this way I have implemented the complete code in front of you with the help of switch statement. Now I'm going to save this code. Nemo file is calc.java and it is saved in d drive inside d drive Java folder. I am opening command prompt so that I can execute this Java code. So I'm moving to D drive then in Java folder. So indeed Java folder calc.java file is available. Now I'm going to execute this code. Sorry, I'm going to compile this code with the help of Java C calc.java. So you can see it is compiled successfully. There is no error. Now with the help of Java calc command, I can execute this code. It is asking for two numbers. I am entering four and six. Now you can see it is asking for a particular choice. So I'm entering one. It is showing addition equals to 10. So case one is working properly. Now let's check any other case. So for that purpose, I need to execute this code once again. So again it is asking for two numbers. I'm entering three four. It is asking for choice. I'm entering three. You can see the multiplication equals to 12 is printed because choice is three. That's why it is calculating multiplication. So this way code is working properly. Let's check default case. I am entering two numbers and choice. I am entering as seven. So you can see it is showing you have entered wrong choice. So this way code is working properly in all the cases. In this way, I have implemented a simple calculator with help of switch. You can add as many features as required in your logic with the following scenario which I have demonstrated you. So you can put many scenarios with help of switch in case in Java program. I hope you have understood how we can implement different scenarios in a single code in Java. Thank you for watching this video.