有几到JAVA题,懂的帮忙给看看吧

来源:百度知道 编辑:UC知道 时间:2024/07/02 13:55:38
1.find all the perfect numbers between 1 and 100
the perfect number met the requirement;
the sun of all factors,(including 1 not incluing the number itself)of this number is eqnal
to the number itself,such us:28=1+2+4+7+14
2.given a score and output a level:(switch)
90-100 A 80-89 B 70-79 C 60-69 D <60:E
3.IN order to get the output like this:
*
***
*****
*******
*****
***
*

哈哈, 1楼太有才了. . 翻译就不用了吧?
第三题 :
public class printDiamond {
public static void main(String[] args) {
int parking = 7/2;
for(int i = 0; i < 7; i++) {
for(int j = 0; j < Math.abs(parking-i); j++) {
System.out.print(" ");
}
for(int j = 0; j < 7-2*Math.abs(parking-i); j++) {
System.out.print("*");
}
System.out.println();
}
}
}

啊... 楼上都给出答案了. 我也懒得写了.....
楼上的答案非常准确. 懒得写了. 楼上把第二题也写出来吧 . ^_^
............................楼上人呢????
第二题 :
import java.util.Scanner;

public class Level {
public static void main(String[] args) {
System.out.println("请输入你的成绩 : ");
while(true) {
try {
Scanner in = new Scanner(System.in);
double d = in.nextDouble();
if(d >= 0 && d <= 100) {
String level = "A";
switch((int)(d / 10)) {