Articles, Blog

Java (Switch-Case) Hesap Makinesi Örneği | Java Dersi 3

December 4, 2019


Hi friends, today with you … … a simple calculator on Netbeans … … as an example. Project Name … … “Calculator.” First we import the Scanner Class. We are importing the class to “public static void” section. Then we define the variables. Enter the first number. Enter the second number. We have made the selection from the code line we have written above. We’re going to Switch-Case. switch (selection) call. I had a result variable … … equals If the person chooses the addition, go to case 1. Add Number 1 and Number 2 to the result variable. “break” we leave the loop. When the user selects the extraction process … … go to case 2. If the user chooses the winner, “collection” “Subtract” if he chooses the second / “Multiplication” if he chooses the third If he chooses the fourth, “Division” I define an error message as “Default”. I’m printing “You made the wrong choice.” Let’s run the program. That’s how we made a simple calculator using switch-case. See you next time.

You Might Also Like

No Comments

Leave a Reply