My first coding experience with Java!

in #blog7 years ago (edited)

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!

Sort:  

Congratulations @ihal0001! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes
Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.029
BTC 61342.71
ETH 2389.65
USDT 1.00
SBD 2.56