nerdexam
CompTIA

FC0-U71 · Question #122

A developer is writing a script to calculate a bank account balance within two decimal places. Which of the following data types should the developer select to store the balance?

The correct answer is C. Float. A float (floating-point number) stores numeric values with a fractional/decimal component, making it appropriate for representing currency values like $1,234.56. Boolean (A) stores only true/false values. Integer (B) stores whole numbers only - it cannot represent cents or…

Software Development Concepts

Question

A developer is writing a script to calculate a bank account balance within two decimal places. Which of the following data types should the developer select to store the balance?

Options

  • ABoolean
  • BInteger
  • CFloat
  • DChar

How the community answered

(30 responses)
  • A
    3% (1)
  • B
    3% (1)
  • C
    93% (28)

Explanation

A float (floating-point number) stores numeric values with a fractional/decimal component, making it appropriate for representing currency values like $1,234.56. Boolean (A) stores only true/false values. Integer (B) stores whole numbers only - it cannot represent cents or fractional amounts. Char (D) stores a single character. Since a bank balance requires precision to two decimal places, float is the correct choice. (Note: In production financial applications, a fixed-point or decimal type is often preferred to avoid floating-point rounding errors, but float is the correct answer among the given options.)

Topics

#Data types#Floating-point numbers#Programming fundamentals#Number representation

Community Discussion

No community discussion yet for this question.

Full FC0-U71 Practice