Friday, February 8, 2013

Week-2: 2.2: Variable : Double

The double variable can hold very large (or small) numbers. The maximum and minimum values
are 17 followed by 307 zeros.

The double variable is also used to hold floating point values. A floating point value is one like
8.7, 12.5, 10.1. In other words, it has a "point something" at the end. If you try to store a floating
point value in an int variable, NetBeans will underline the faulty code. If you try to run the
programme, the compiler will throw up an error message.
Let's get some practise using doubles.
Change the int from your previous code to double. So change this:

int first_number, second_number, answer;
to this:
double first_number, second_number, answer;
Now change the values being stored:
first_number = 10.5;
second_number = 20.8;

Visit for Details

1 comment:

  1. package javadivide;
    import java.util.Scanner;
    public class JavaDivide
    public static void main(String[] args)
    double First_digit=25.5,Second_digit=25.5;
    float Answer=0;
    Scanner input=new Scanner (;
    Answer=(float) ((First_digit+Second_digit)/4);
    System.out.println("Divide Result is = " + Answer);