请哪位Java高手帮我看看这些题

来源:百度知道 编辑:UC知道 时间:2024/05/26 04:07:22
请哪位Java高手帮我看看这些题,一共有三题,能帮一题算一题,记得要体现面向对象的思想,最好适当做一下注释,不然本人能力有限,可能看起来有难度哦。
1.设计一个银行账户类,其中包括以下内容,并用字符界面模拟存款和取款过程.
(1)账户信息 :帐号,姓名,开户时间,身份证号码.
(2)存款方法.
(3)取款方法.
(4)其他方法,如”查询余额”和”显示帐号”等.
2.编写求解几何图形周长,面积的应用程序,要求如下:
(1)几何图形要求至少包含直线,三角形,矩形,圆等类型.
(2)能计算俩个图形之间的距离(形心).
(3)要求使用接口和内部类.
3.水仙花是三位数,它的各位数字的立方和等于这个三位数本身,例如371=33+73+13,则371就是一个水仙花数.编程找出所有水仙花数.

public class Sxhshu {

public static void main(String[] args) {
for (int i = 100; i < 100000; i++) {
if (issxhshu(i))
System.out.print(" "+i);
}
}

public static boolean issxhshu(int shu) {
int count = 0;
String text = Integer.toString(shu);
int lenth = text.length(); // 判定是几位数

for (int i = 0; i < lenth; i++) {
count += Math.pow(text.charAt(i) - 48, lenth); // 算法累加
}
if (count == shu) // 判定是否为水仙花数
return true;
else
return false;
}
}

3.求1000以内所有的水仙花数

public class Test{
public static void main (String args[])
{
int n=100;
while(n<=1000)
{
int i,j,k;
i=n/100;
j=(n-i*100)/10;
k=n%10;
if((Math.pow(i, 3)+Math.pow(j, 3)+Math.pow(k, 3))==n)

System.out.print(n+String.valueOf('\t'));
n++;
}