用java编程 求2的16次方程序应该怎么写
- 提问者网友:余味
- 2021-03-06 07:45
- 二级知识专家网友:24K纯糖
- 2021-03-06 08:36
for(int i=0;i<16;i++)
{
y=y*2;
}
System.out.println(y);
- 1楼网友:山鬼偶尔也合群
- 2021-03-06 11:44
- 2楼网友:夢想黑洞
- 2021-03-06 10:53
// phone.java
public class phone{
//说明:电话号码是由一定规则组成的,所以建议使用string类型
//本机号码
private string ownno;
public void setownno(string ownno){
this.ownno=ownno;
}
public string getownno(){
return ownno;
}
//打电话
public void makecall(string targetno){
//具体实现
system.out.println("呼叫:"+targetno);
}
//接电话
public void answercall(string targetno){
//具体实现
system.out.println("应答来电号码:"+targetno);
}
}
//接口 moveable.java
public interface moveable{
//接口方法默认为 public abstract 的,所以可以不用写public
void sendmsg(string targetno,string msg);
//接收消息
void getmsg(string targetno,string msg);
}
//移动电话类 mobilephone.java
public class mobilephone extends phone implements moveable{
//打电话
public void makecall(string targetno){
//具体实现
system.out.println("移动电话呼叫:"+targetno);
}
//接电话
public void answercall(string targetno){
//具体实现
system.out.println("移动电话应答电话,来电号码:"+targetno);
}
public void sendmsg(string targetno,string msg){
system.out.println("向:"+targetno+"\n发送消息:"+msg);
}
public void getmsg(string targetno,string msg){
system.out.println("接收:"+targetno+"\n消息内容:"+msg);
}
}
//固定电话类 fixedphone.java
public class fixedphone extends phone{
//打电话
public void makecall(string targetno){
//具体实现
system.out.println("固定电话呼叫:"+targetno);
}
//接电话
public void answercall(string targetno){
//具体实现
system.out.println("固定电话应答电话,来电号码:"+targetno);
}
}
//无绳电话 cordlessphone.java
public class cordlessphone extends fixedphone {
//新特性 ,可以移动
private boolean canmove;
public boolean getcanmove(){
return canmove;
}
public void setcanmove(boolean canmove){
this.canmove=canmove;
}
//打电话
public void makecall(string targetno){
//具体实现
system.out.println("无绳电话呼叫:"+targetno);
}
//接电话
public void answercall(string targetno){
//具体实现
system.out.println("无绳电话应答电话,来电号码:"+targetno);
}
}
//好了,基本上完了,等下把测试类提交上来,在这上面编辑就是恼火,格式不好控制,你自己调下
- 3楼网友:山鬼偶尔也合群
- 2021-03-06 10:45
- 4楼网友:滚出爷的世界
- 2021-03-06 09:07