IDEONE Java Basics 102 – Double Variables
PREREQUISITE
This tutorial uses the online compiler IDEone (www.ideone.com ).
IDEone gives you few benefits:
1) Zero setup. You just need Internet Connection and a modern Web Browser.
2) Online storage. You can refer back to the codes at later time.
3) Public codes available. You can also see how others write codes and learn from them as well.
4) Online Learning. You can ask a companion at remote location to help edit the codes or review your codes for improvements or troubleshooting algorithms.
STEPS
1) Start with the basic template
Browse http://ideone.com/l3lzo6
Clone the code above. (Click the Fork button).
2) Edit the codes.
2-1) Change the variable data type in declaration statement.
double first_number, second_number, answer;
|
2-2) Change the values in assignment statement.
first_number = 10.5;
second_number = 20.8;
|
2-3) Run.
2-4) Change the operator in the operation statement.
answer = first_number / second_number;
|
2-5) Change the string value in the output statement.
System.out.println("Result = " + answer);
|
2-6) Run.
Lessons:
- Use Double to store decimal point numbers
- Double format is a computer number format that occupies 8 bytes (64 bits) in computer memory and represents a wide dynamic range of values by using floating point.
No comments:
Post a Comment