This quick tutorial will show you how to create a simple java program using Java scanner class. This program will ask for two integers, then sum them up and finally print out the answer on the screen. The simple code is as follow:
import java.util.Scanner;
public class PlusNumber {
public static void main(String[] args) {
int firstNumber;
int secondNumber;
int total;
Scanner input = new Scanner(System.in);
System.out.print("Enter first integer : ");
firstNumber = input.nextInt();
System.out.print("Enter second integer : ");
secondNumber = input.nextInt();
total = firstNumber + secondNumber;
System.out.println("The total is : " + total);
}
}
The outcome of the program is as follow:
This is a really simple c sharp program which will create a text file with some data on it – code provided
Read More Changing the content of a memory address with c programSimple c program showing you how to change the value of a content through the pointer.
Read More How to use the strstr() function in c programThis article will show you how to use the strstr() function in c program
Read More Simple c language program related to an array of pointersSimple c language program showing you how to use an array of pointers to store the memory address of each array element – code provided
Read More How to change the first character of a string using the pointer in c programSimple c program showing you how to write a program which will change the first character of a string accordingly.
Read More How to pass an array variable to a function in c programSimple c program showing you how to pass an array into a function and then change the content of that whole array
Read More How to store the memory location of a variable in a pointer variable with c programThis article will show you how to store the memory location of a variable in a pointer variable with c program
Read More How to find out the memory location (address) of a variable with c programThis simple c program will show you how you can find a memory location of a variable temporary stores inside the RAM of your personal computer for the usage of that c program.
Read More How to compile the java program with javac from the DOS command prompt in Windows?This post will show you how to compile the java program with javac from the DOS command prompt in Windows with java program sample provided.
Read More Java source code for creating a simple rectangle boxFull java source code for creating a simple 500 x 300 rectangle box
Read More This is how the javascript or operator worksExamples showing you how to use the javascript or operator.
Read More How to perform the Java BigDecimal type’s subtractionExample showing you how to perform the Java BigDecimal type’s subtraction
Read More How to use the Java BigInteger class with source code providedExample showing you how to use the Java BigInteger class with source code provided
Read More