编写一个Java应用程序,该应用程序包括2个类:Print类和主类E。Print 类里有一个方法output()功能是输出100 ~ 999之间的所有水仙花数(各位数字的 立方和等于这个三位数本身,如: 371 = 33 + 73 + 13。)在主类E的main方法中来 测试类Print。
package liu0917;
public class Print
{
void output()
{
for(int i =100;i<=999;i++)
{
if(Math.pow(i/100,3)+Math.pow(i%10,3)+Math.pow(i/10%10, 3)==i)
{
System.out.println(i);
}
}
}
}
package liu0917;
public class E {
public static void main(String[] args)
{
Print pr=new Print();
pr.output();
}
}


浙公网安备 33010602011771号