![](https://csdnimg.cn/release/download_crawler_static/87849425/bg5.jpg)
自考 04747《Java 语言程序设计(一)》编程题全集(50 题及答案)
} else if(x 〉 100) {
y = 20 * 0、175 + 40 * 0、08 + 40 * 0、015 + (x - 100) * 0、01;
}ﻫ System、out、println("应该提取得奖金就是 " + y + "万");
}
}
【程序 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又就是一个完
全平方数");
}ﻫ }
}ﻫ}ﻫ}ﻫ
/*按题意循环应该从—100开始(整数包括正整数、负整数、零),这样会多一个满足条件
得数-99.ﻫ但就是我瞧到大部分人解这道题目时都把题中得“整数”理解成正整数,我也就随大
流了.*/
【程序 14】 ﻫ题目:输入某年某月某日,判断这一天就是这一年得第几天?
import java、util、*;ﻫpublic class lianxi14 {ﻫpublic static void mai
n(String[] args) {ﻫ int year, month, day;
int days = 0;ﻫ int d = 0;
int e;ﻫ input fymd = new input();ﻫ do {ﻫ e = 0;
System、out、print("输入年:”);ﻫ year =fymd、input();ﻫ System、
out、print(”输入月:");
month = fymd、input();
System、out、print("输入天:”);
day = fymd、input();ﻫ if (year < 0 || month < 0 || month > 12 ||
day < 0 || day > 31) {ﻫ System、out、println("输入错误,请重新输入!");
e=1 ; ﻫ} ﻫ }while( e==1);ﻫ for (int i=1; i <month; i++)
{
switch (i) {ﻫ case 1:
case 3:
case 5:ﻫ case 7:
case 8:ﻫ case 10:
case 12:
days = 31;
break;ﻫ case 4:
case 6:ﻫ case 9:ﻫ case 11:
days = 30;
break;
case 2:ﻫ if ((year % 400 == 0) || (year % 4 == 0 && year %
100 != 0)) {ﻫ days = 29;ﻫ } else {ﻫ days = 28;
}