Simple Calculator Program with Java

  • Hello Jetto Family,

    I will show you a calculator programme with a simple algorithm model in Java.

    First of all, open any editor, IDE or notepad!

    I will explain here on IntelliJ IDEA Community Edition! IntelliJ IDEA is a paid programme, but Community Edition is free!

    You can find the download link by doing a short search on Google. 🙂

    When you open the programme, you first need to import the library required to get data from the console!

    Java
    import java.util.Scanner;

    You must define the above code above the Main class in the program.

    231-img-20240214-105336-157-png

    Then we will start writing our codes in the main function!

    232-img-20240214-105737-562-png

    First of all, we defined an object from the library we imported. We will use it when getting information from the console.

    Then we get the first number and the second number from the console and assign them to variables.

    All that remains is to do the operations and print them on the screen!

    I am doing the simplest version here. Of course, it can be progressed by asking the user what to do. You can make better ones by developing!

    233-img-20240214-110452-787-png

    As above, we use the calculations in the command to print to the screen.

    Finally, you can specify a message according to your wishes. I have written the message ‘Calculation completed!’.

    234-img-20240214-110455-854-png

    Thus, we have finished the program! Now it's time to put it to work!

    235-img-20240214-111140-306-png

    As you can see, by entering two numbers, we have successfully performed the operation we wanted!

    You can send your questions as a comment.

    All codes:

Şimdi katılın!

Henüz hesabınız yok mu? Topluluğumuzun aktif bir üyesi olun ve oyunlarla, yazılımlarla ilgili ilginç konuları keşfedin! Kaydolun ve tartışmalara katılın, deneyimlerinizi paylaşın ve yeni arkadaşlar edinin. Topluluğumuzda herkesin kendine göre bir yer bulabileceğinden eminiz. Hadi, gelin ve bizimle birlikte eğlenceli ve bilgilendirici bir yolculuğa çıkın!