My first coding experience with Java!

ihal0001(46)
Published in
#blog
Words
147
Reading
1 min
Listen
Play
8y

Today I had the privilege of having my very first coding experience in Java for collage. It was quite fun! we learnt how to ask a user to input a number in a dialog box and then a second and third number, calculate it and then return the answer. Yes i know its simple, but this was my first time...

// this is a calculation
// Prints answer of 3 numbers added
import javax.swing.JOptionPane;
public class Task7
{
public static void main(String args[])
{
String numString1 = JOptionPane.showInputDialog("Input first number");

    int firstNum = Integer.parseInt(numString1);

    String numString2 = JOptionPane.showInputDialog("Input second number");

    int secondNum = Integer.parseInt(numString2);

    String numString3 = JOptionPane.showInputDialog("Input Third number");

    int thirdNum = Integer.parseInt(numString3);

    int Result = firstNum + secondNum + thirdNum;

    JOptionPane.showMessageDialog(null,Result);
}

}

Result:

First box.PNG

Second box.PNG

Third box.PNG

Answer.PNG

I thought this was quite cool!

Please promote my blogs if you enjoy them, there will be many more to come!

My first coding experience with Java! | Ecency