CSCI 1111 Lecture Notes - Lecture 3: Operand, Pseudorandom Number Generator, Type Conversion

48 views2 pages

Document Summary

A variable need to store a decimal occasionally: defined as type double stores a floating point number. A floating point literal is a number with a fractional part (0. 0, 99. 5) Using scientific notion is written as e (6. 02e23 = 6. 02 * 1023) Programming example: given sphereradius and pival, compute the volume of a sphere and assign to spherevolume, use (4. 0/3. 0) to perform floating point division. The keyword final makes a variable constant, and unchanging cannot be modified. An input value to a method goes between parentheses and is known as an argument. Using a math method from the math class: double sidesquare = 0. 0, double areasquare = 49. 0, sidesquare = math. sqrt(areasquare) Example computing the volume of a sphere: spherevolume = (4. 0/3. 0) * pival * math. pow(sphereradius,3); A calculation must mix integer and floating point numbers sometimes. A type conversion is a conversion of one data type to another (int to double)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents