Jeanette is creating a game about winning a lottery. She will create variables that track dollars and cents in decimal form. Which data type should she use to store this data?

Prepare for the ICT Gaming Essentials Exam. Use flashcards and multiple choice questions, each with hints and explanations. Ace your exam!

Multiple Choice

Jeanette is creating a game about winning a lottery. She will create variables that track dollars and cents in decimal form. Which data type should she use to store this data?

Explanation:
The main idea is choosing a numeric type that can store decimal values. A floating point type holds real numbers with fractional parts, so it can represent amounts like 12.50 or 0.99 and perform arithmetic on them. This makes it suitable for dollars and cents, which always include a fractional component. Integer types can't represent the decimal portion, strings would treat the amount as text rather than a number you can compute with, and booleans are just true/false values, not numbers. Keep in mind that floating point can introduce tiny rounding errors in exact monetary calculations, so for precise currency handling some systems use decimal or fixed-point types (or store cents as integers). But for storing dollars and cents in decimal form, floating point is the appropriate choice.

The main idea is choosing a numeric type that can store decimal values. A floating point type holds real numbers with fractional parts, so it can represent amounts like 12.50 or 0.99 and perform arithmetic on them. This makes it suitable for dollars and cents, which always include a fractional component. Integer types can't represent the decimal portion, strings would treat the amount as text rather than a number you can compute with, and booleans are just true/false values, not numbers. Keep in mind that floating point can introduce tiny rounding errors in exact monetary calculations, so for precise currency handling some systems use decimal or fixed-point types (or store cents as integers). But for storing dollars and cents in decimal form, floating point is the appropriate choice.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy