JAVA编程题全集(100题及答案) 联系客服

发布时间 : 星期五 文章JAVA编程题全集(100题及答案)更新完毕开始阅读19e3944ebcd5b9f3f90f76c66137ee06eef94e16

.

public static void main(String[] args) {

System.out.println(\到1000的完数有: \ for(int i=1; i<1000; i++) { int t = 0;

for(int j=1; j<= i/2; j++) { if(i % j == 0) { t = t + j; } }

if(t == i) {

System.out.print(i + \\ } } }

【程序10】

题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在10次落地时,共经过多少米?第10次反弹多高? public class lianxi10 {

public static void main(String[] args) { double h = 100,s = 100; for(int i=1; i<10; i++) { s = s + h;

可编辑

第 .

h = h / 2; }

System.out.println(\经过路程:\ System.out.println(\反弹高度:\} }

【程序11】

题目:有1、2、3、4四个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? public class lianxi11 {

public static void main(String[] args) { int count = 0;

for(int x=1; x<5; x++) { for(int y=1; y<5; y++) { for(int z=1; z<5; z++) { if(x != y && y != z && x != z) { count ++;

System.out.println(x*100 + y*10 + z ); } } } }

System.out.println(\共有\个三位数\

可编辑

.

} }

【程序12】

题目:企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润,求应发放奖金总数? import java.util.*; public class lianxi12 {

public static void main(String[] args) { double x = 0,y = 0;

System.out.print(\输入当月利润(万):\ Scanner s = new Scanner(System.in); x = s.nextInt(); if(x > 0 && x <= 10) { y = x * 0.1;

} else if(x > 10 && x <= 20) { y = 10 * 0.1 + (x - 10) * 0.075; } else if(x > 20 && x <= 40) {

y = 10 * 0.1 + 10 * 0.075 + (x - 20) * 0.05;

可编辑

.

} else if(x > 40 && x <= 60) {

y = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + (x - 40) * 0.03; } else if(x > 60 && x <= 100) {

y = 20 * 0.175 + 20 * 0.05 + 20 * 0.03 + (x - 60) * 0.015; } else if(x > 100) {

y = 20 * 0.175 + 40 * 0.08 + 40 * 0.015 + (x - 100) * 0.01; }

System.out.println(\应该提取的奖金是 \万\} }

【程序13】

题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少? public class lianxi13 {

public static void main(String[] args) { for(int x =1; x<100000; x++) { if(Math.sqrt(x+100) % 1 == 0) { if(Math.sqrt(x+268) % 1 == 0) {

System.out.println(x + \加100是一个完全平方数,再加168又是一个完全平方数\ } }

可编辑