首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。 【说明】清点盒子。本程序当用户输入一个整数值时,一切正常;当输入其他数值时,程序就出错。现在已做了改进,请填空。 import java. text. NumberFormat;
阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。 【说明】清点盒子。本程序当用户输入一个整数值时,一切正常;当输入其他数值时,程序就出错。现在已做了改进,请填空。 import java. text. NumberFormat;
admin
2009-02-15
37
问题
阅读下列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://jikaoti.com/ti/J2i7FFFM
本试题收录于:
软件设计师下午应用技术考试题库软考中级分类
0
软件设计师下午应用技术考试
软考中级
相关试题推荐
函数f()、g()的定义如下所示,已知调用f时传递给其形参x的值是10,若以传值方式调用g,则函数f的返回值为__________。
以下关于用例图的叙述中,不正确的是(44)。图书馆管理系统需求中包含“还书”用例和“到书通知”用例,对于“还书”用例,应先查询该书是否有人预定,若有则执行“到书通知”。“还书”用例和“到书通知”用例是(45)关系,以下用例图中,(46)是正确的。管理员处
不同加密机制或算法的用途、强度是不相同的,一个软件或系统中的加密机制使用得是否合理,强度是否满足当前要求,是需要通过测试来完成的,通常_______是测试的一个重要手段。
X软件公司的软件工程师张某兼职于Y科技公司,为完成Y科技公司交给的工作,做出了一项涉及计算机程序的发明。张某认为该发明是利用自己的业余时间完成的,可以以个人名义申请专利。此项专利申请权应归属()。
用户访问某Web网站,浏览器上显示“HTTP-404”错误,则故障原因是(70)。
在面向对象分析和设计中,用类图给出系统的静态设计视图,其应用场合不包括___________(45)。下图是一个UMI,类图,其中类University和类School之间是___________(46)关系,类Person和类PersonRecord之间
POP3协议采用___________(23)模式,客户端代理与POP3服务器通过建立___________(24)连接来传送数据。(24)
某企业的生产流水线上有2名工人P1和P2,1名检验员P3。P1将初步加工的半成品放入半成品箱B1;P2从半成品箱B1取出继续加工,加工好的产品放入成品箱B2;P3从成品箱B2取出产品检验。假设B1可存放n件半成品,B2可存放m件产品,并设置6个信号量S1、
对于以下编号为①、②、③的正规式,正确的说法是(35)。①(aa*|ab)*b②(a|b)*b③((a|b)*|aa)*b
(1)请说明流程图1中的文件F0、F1分别是哪个文件。(2)处理1和处理5分别按照哪些数据项进行分类?说明处理6的功能。【流程图】(如图3所示)
随机试题
原子吸收法是根据基态原子和激发态原子对特征波长吸收而建立起来的分析方法。()
A.医生为患者做检查时,由于消毒观念不强造成交叉感染B.医生的行为使某个患者受益,但却损害了别的患者的利益C.医生对患者的呼叫或提问给予应答D.妊娠危及孕妇的生命时,医生给予引产E.医生泄露患者的个人隐私上述各项中属于医生违背尊重原则的是
用于控制支气管哮喘急性发作的药物是
来源于豆科且含黄酮类成分的药材有
下列说法错误的是( )。
有时候我们会高估自己低估别人.有的时候我们会以自己的眼光看待别人,有时候面对重大事件会存在侥幸心理,你存在这种情况吗?你怎么解决的?
政府的功能是满足人民群众的真正需要,除非政府知道那些需要是什么,否则政府就无法满足那些需要,言论自由能确保政府官员听到这样的需求信息,因此,对一个健康的国家来说,言论自由是必不可少的。下面哪一项如果为真,不能削弱上述论证?
请在“答题”菜单下选择“演示文稿”命令,然后按照题目要求再打开相应的命令,完成下面的内容,具体要求如下:注意:下面出现的所有文件都必须保存在考生文件夹下。打开考生文件夹下的演示文稿yswg.pptx,按照下列要求完成对此文稿的修饰并保存。
Inthepast,theParkServicefocusedonmakingthebigscenicparksmore【21】______andcomfortablefortourists.Roadswere
TheSantaAnaappealscourtupheldanearlierjuryverdictawarding$3.2millionindamagestoAlexisSartiwhosufferedserio
最新回复
(
0
)