首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。 【说明】清点盒子。本程序当用户输入一个整数值时,一切正常;当输入其他数值时,程序就出错。现在已做了改进,请填空。 import java. text. NumberFormat;
阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。 【说明】清点盒子。本程序当用户输入一个整数值时,一切正常;当输入其他数值时,程序就出错。现在已做了改进,请填空。 import java. text. NumberFormat;
admin
2009-02-15
39
问题
阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。
【说明】清点盒子。本程序当用户输入一个整数值时,一切正常;当输入其他数值时,程序就出错。现在已做了改进,请填空。
import java. text. NumberFormat;
Public class InventoryLoop
{
public static void main(String args[])
{
String numBoxesIn;
Int numBoxes;
Double boxPrice=3.25;
Boolean gotGoodInput=false;
NumberFormat currency=NumberFormat.(1);
do
{
System.out. print(“How many boxes do we have?”);
numBoxesIn=DummiesIO. (2);
try
{
numBoxes=Integer.parseInt((3));
system. out. print("The value is");
system.out. println(currency, format (numBoxes*boxPrice));
gotGoodInput=true;
catch((4))
{
System.out.println();
System.out. println(That’s not a number.");
}
}while((5));//输入不正确时
System. out.println("That’s that.");
}
}
选项
答案
(1)getCurrencyInstance()或getCurrencyInstance(currentLocale) (2)getString() (3)numBoxesIn (4)NegativeNumberException e (5)!gotGoodInput
解析
(1)getCurrencyInstance()或getCurrencyInstance(currentLocale)
货币currency对象指向格式化数据NumberFormat类的货币数字格式getCurrencyInstance()。
(2)getString()
读入货币数字的字符串到NumBoxesIn中。
(3)numBoxesIn
分析字符串NumBoxesIn的合法性,并转换成整数。
(4)NegativeNumberException e
捕捉数据格式错误的信息NegativeNumberException e。
(5)!gotGoodInput
输入不正确时,继续循环输入。
转载请注明原文地址:https://kaotiyun.com/show/LgDZ777K
本试题收录于:
软件设计师下午应用技术考试题库软考中级分类
0
软件设计师下午应用技术考试
软考中级
相关试题推荐
软件测试的对象不包括________。
在汇编指令中,操作数在某寄存器中的寻址方式称为______寻址。
在机器指令的地址字段中,直接指出操作数本身的寻址方式称为___________。
在结构化分析方法中,利用分层数据流图对系统功能建模。以下关于分层数据流图的叙述中,不正确的是___________(32)。采用数据字典为数据流图中的每个数据流、文件、加工以及组成数据流或文件的数据项进行说明,其条目不包括____________(33)。
POP3协议采用___________(23)模式,客户端代理与POP3服务器通过建立___________(24)连接来传送数据。(23)
软件工程每一个阶段结束前,应该着重对可维护性进行复审。在系统设计阶段的复审期间,应该从(8)出发;评价软件的结构和过程。
在结构化分析方法中,数据流图描述数据在系统中如何被传送或变换,反映系统必须完成的逻辑功能,用于(38)建模。在绘制数据流图时,(39)。(39)
若某文件系统的目录结构如下图所示,假设用户要访问文件f1.java,且当前工作目录为Program,则该文件的全文件名为(24),其相对路径为(25)。 (25)
修改现有软件系统的设计文档和代码以增强可读性,这种行为属于________维护。
ISO/IEC9126《软件工程产品质量》统一了多种质量模型。其中,下述关于软件使用质量的描述,不正确的是______。A.它测量用户在特定环境中能达到其目标的程度,不是测量软件自身的属性B.使用质量的属性分为4个特性:有效性、生产率、安全性和满意度
随机试题
国务院总理在选举时人选由________提名。()
在下列组织结构中,最有可能产生集权领导的组织形式是()
下列享有对该部长篇小说的著作权的人包括()。音像出版社发行包含影片片头曲的磁带是否侵犯他人著作权?为什么?()
下列不属于动态控制中的三大要素的是()。
根据《合同法》的规定,下列各项中,债权人不可以行使撤销权的情形有()。
依据税法规定,对出口商品退还增值税、消费税的,均不退还已缴纳的城市维护建设税。()
教师公正的核心是()。
随着信息技术的发展,旅游网站成为传播旅游信息资源的重要渠道,是大部分潜在游客出行前搜寻信息的主要参考来源。据统计,有61.2%的旅游者出行时会选择从网上搜寻信息,而且网络旅游信息具有搜寻成本低、传播快的特点,成为重要的信息载体和影响旅游者决策的因素。这段文
空中花园
______hetriedtopassthedrivingtest,hestillfailedthesecondtime.
最新回复
(
0
)