首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请将下面程序补充完整。 public class PowerCalc{ public static void main(String[]args){ double x=5.0; S
请将下面程序补充完整。 public class PowerCalc{ public static void main(String[]args){ double x=5.0; S
admin
2009-08-24
41
问题
请将下面程序补充完整。
public class PowerCalc{
public static void main(String[]args){
double x=5.0;
System. out. println(x+"to the power 4 is"+power(x, 4));
System. out. println("7. 5 to the power 5 is"+power(7.5, 5));
System. out. println("7.5 to the power 0 is"+power(7.5, 0));
System. out. println("10 to the power -2 is"+power(10, -2));
}
static double【 】 (double x, int n){
if(n>1)
return x * power(x, n-1);
else if(n<0)
return 1.0/power(x, -n);
else
return n==0 ? 1.0:x;
}
}
选项
答案
【 】power
解析
通过程序片段可看出,在main方法中调用了。power方法,所以需要在类中对power方法进行定义,否则编译会报错。下面的程序片段就是对power方法的定义。
转载请注明原文地址:https://jikaoti.com/ti/8ob0FFFM
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
在项目管理器的“数据”选项卡中按大类划分可以管理
假设职员表已在当前工作区打开,其当前记录的“姓名”字段值为“李彤”(C型字段)。在命令窗口输入并执行如下命令:姓名=姓-’’出勤’’?姓名屏幕上会显示
为了隐藏在文本框中输入的信息,用占位符代替显示用户输入的字符,需要设置的属性是
设有学生表student(学号,姓名,性别,出生日期,院系)、课程表course(课程号,课程名,学时)和选课表score(学号,课程号,成绩),查询选修课程在5门以上(含5门)的学生的学号、姓名和平均成绩,并按平均成绩降序排序,正确的命令是
一棵二叉树中共有80个叶子结点与70个度为1的结点,则该二叉树中的总结点数为
在VisualFoxPro中,下列程序段执行后,内存变量e的值是a=300b=200c=100d=IIF(a>b,a,b)e=IIF(c>d,c,d)
在考生文件夹下,打开学生数据库sdb,完成如下简单应用:(1)使用报表向导建立一个简单报表。要求选择student表中所有字段;记录不分组;报表样式为“随意式”;列数为“1”,字段布局为“列”,方向为“纵向”;排序字段为“学号”(升序);报表标题为“学生
在VisualFoxPro中,要运行查询文件Student.qpr,可以使用命令()。
结构化程序设计的基本原则不包括()。
考生文件夹下存在一个文件“PY103.py”,请写代码替换横线,不修改其他代码,实现以下功能。用键盘输入十进制整数,按要求将这个整数转换为二进制、八进制及十六进制(大写)并输出到屏幕。例如:输入数字:425对应的二进制数:110101001对应的
随机试题
便秘按发病机制主要分为两大类,分别是
外科急腹症患者,在未明确诊断时应严格四禁。下列哪项不属于四禁内容
进出口货物的收发货人的权利有:()
按照《证券公司监督管理条例》的要求,证券公司要建立完备的内部控制体系。证券公司以保护投资者利益和防范证券公司风险为出发点,重点规定了()主要业务的规则和风险控制措施。Ⅰ.证券经纪业务Ⅱ.证券自营业务Ⅲ.证券资产管理业务Ⅳ.证券公
某企业2010年息税前利润为800万元,固定成本(不含利息)为200万元,预计企业2011年销售量增长10%,固定成本(不含利息)不变,则2011年企业的息税前利润会增长()。
物权法的基本原则中物权绝对性原则,是()的。
()被誉为“济南第一名石”。
某公司网上销售管理系统的数据库部分关系模式如下所示。其中,客户号唯一标识一位客户,产品号唯一标识一件产品,订单号唯一标识一份订单。一份订单必须且仅对应一位客户,一份订单可由一到多条订单明细组成,一位客户可以有多份订单。客户(客户号,姓名,性别,地址
有以下程序:intsub(intn){return(n/10+n%10);}main(){intx,y;scanf("%d",&x);y=sub(sub(sub(x)));printf
在考生文件夹下,打开文档WORD1.DOCX,按照要求完成下列操作并以该文件名(WORD1.DOCX)保存文档。将正文第二段(“美国DisplaySearch研究公司……轻微上扬的可能。”)分为等宽的两栏,栏宽设置为18字符。
最新回复
(
0
)