复制
收藏
提问
简洁

What variable type should be used for the following pieces of data? (a) A message that should be printed. (b) The current year. (c) A sprinter’s total time (chip time) when running the 100m. (d) A collection of customer names. (e) A look-up to find a customer’s telephone number from their customer ID. (f) An unordered collection of numbers (without repeats). (g) The answer to the question: ”Is Shakespeare still alive?”

1c9ab6955
2个月前
全网
文档
学术
百科
知识库
时间不限
自动
回答简洁模式
深入研究一些

变量类型选择

  • (a) 打印消息:应使用字符串类型(String),因为需要存储文本信息。2689
  • (b) 当前年份:应使用整数类型(Integer),因为年份是整数值。1379
  • (c) 短跑运动员的总时间:应使用浮点数类型(Float),因为时间通常有小数部分。17910
  • (d) 客户姓名集合:应使用列表类型(List),因为需要存储多个不重复的项。28
  • (e) 根据客户ID查找电话号码:应使用映射类型(如字典或哈希表),因为需要通过键值对进行查找。8
  • (f) 无序不重复的数字集合:应使用集合类型(Set),因为集合元素唯一且无序。8
  • (g) 判断莎士比亚是否还活着:应使用布尔类型(Boolean),因为答案只有真或假。26
你觉得结果怎么样?

以上内容由AI搜集生成,仅供参考

在线客服