Arizona State University (ASU) CSE110 Principles of Programming Exam 1 Practice

Session length

1 / 500

In an airline reservation system, the cost of an airline ticket is required. Which data type should be used to store this value?

int

byte

double

The most appropriate data type for storing the cost of an airline ticket is a double. This is because a double can represent decimal numbers with precision, which is essential for financial values like ticket prices that often include cents. For example, a ticket price could be $199.99 or $250.50, both of which require the ability to store fractions of a whole number.

Using a double ensures that calculations involving ticket prices, like total costs or discounts, can be performed accurately without losing any decimal value. In contrast, other data types like int, byte, and short are designed for whole numbers and would not be suitable for representing the ticket prices that require decimal precision. Int can hold larger whole numbers, but not decimal points, while byte and short have even more limited ranges and are not intended for monetary values.

Get further explanation with Examzify DeepDiveBeta

short

Next Question
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy