Java Scanner Class

Post on January 5th, 2012 @ 11:29 PM by |Posted in : programming languages | Tagged in : , , | No Comment |Send Email

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:


continue on : Simple program to create a data text file with c sharp (c#)

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 program

Simple 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 program

This article will show you how to use the strstr() function in c program

Read More

Simple c language program related to an array of pointers

Simple 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 program

Simple 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 program

Simple 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 program

This 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 program

This 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 box

Full java source code for creating a simple 500 x 300 rectangle box

Read More

This is how the javascript or operator works

Examples showing you how to use the javascript or operator.

Read More

How to perform the Java BigDecimal type’s subtraction

Example showing you how to perform the Java BigDecimal type’s subtraction

Read More

How to use the Java BigInteger class with source code provided

Example showing you how to use the Java BigInteger class with source code provided

Read More


Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>