Friday, February 8, 2013

Week-2: 2.1: Variable: Integer


Programs work by manipulating data placed in memory. The data can be numbers, text,
objects, pointers to other memory areas, and more besides. The data is given a name, so that it
can be re-called whenever it is need. The name, and its value, is known as a Variable. We'll start
with number values.

To store a number in java, you have lots of options. Whole numbers such as 8, 10, 12, etc, are
stored using the int variable. (The int stands for integer.) Floating point numbers like 8.4, 10.5,
12.8, etc, are stored using the double variable. You do the storing with an equals sign ( = ). Let's
look at some examples (You can use your FirstProject code for these examples).

Click for Details


4 comments:

  1. Mohammad Ashraful Hasan Sobuj
    My Batch- 46th
    My Department :CSE
    My ID 201420656

    package firstlover
    public class FirstLover
    }
    public static void main(string[] args)
    {
    int first_lover, second_lover, answer;
    first_lover = 100;
    second_lover = 50;
    answer = first_lover + second_lover;
    System.out.println("Addition Total = " + answer );
    }

    ReplyDelete
  2. package addition;
    public class Addition
    {
    public static void main(String[] args)
    {
    int a=20;
    a=a+20;
    System.out.println("The value is:"+a);
    }

    }

    ReplyDelete
  3. package javasum;
    import java.util.Scanner;
    public class JavaSum
    {
    public static void main(String[] args)
    {
    int First_digit=20,Second_digit=30,Sum=0;
    Scanner input=new Scanner (System.in);
    Sum=First_digit+Second_digit;
    System.out.println("Sum is = " +Sum);
    }
    }

    ReplyDelete
  4. package multiplication;
    public class multiplication
    {
    public static void main(String[] args)
    {
    int a=20;
    int b=10;
    int c=a*b;
    System.out.println("The value is:"+c);
    }

    }

    ReplyDelete