import java.util.Scanner;
// 一个Java源文件中可以有多个类,但是只能有一个public类
// 多个类中可以有多个 main 方法,一个类中只能有一个 main 方法
// 使用的时候,先编译Java源文件 javac HomeWork01.java ,
// 在通过 java 类名 (java HomeWork04) 的方法在命令行中运行
public class HomeWork01{
public static void main(String[] args){
double totalMoney = 100000.0;
double money = totalMoney;
int count = 0; // 统计可以经过路口的次数
while(true){
if(money > 50000){
money -= money * 0.05;
}else if(money > 0 && money <= 50000){
money -= 1000;
}else{
break;
}
count++;
}
System.out.println(count);
}
}
class HomeWork02{
public static void main(String[] args){
//判断某一年是否为闰年
Scanner sc = new Scanner(System.in);
while(true){
System.out.println("请输入年份(输入-1退出判断):");
int year = sc.nextInt();
if(year == -1){
break;
}
if( ( year % 400 == 0 ) || ( year % 100 != 0 && year % 4 == 0 )){
System.out.println(year + "年是闰年");
}else{
System.out.println(year + "年不是闰年");
}
}
}
}
class HomeWork03{
public static void main(String[] args){
//判断水仙花数
Scanner sc = new Scanner(System.in);
while(true){
System.out.println("请输入一个三位数字(输入-1退出循环):");
int isNarcissusNum = sc.nextInt();
if(isNarcissusNum == -1){
break;
}
int ge = isNarcissusNum % 100 % 10; // 获取个位上的数
int shi = isNarcissusNum / 10 % 10; // 获取十位上的数
int bai = isNarcissusNum / 100; //获取百位上的数字
if( isNarcissusNum == ge * ge * ge + shi * shi * shi + bai * bai * bai){
System.out.println(isNarcissusNum + "是水仙花数");
}else{
System.out.println(isNarcissusNum + "不是水仙花数");
}
}
}
}
class HomeWork04{
public static void main(String[] args){
//判断1-100之间不能被5整除的数
Scanner sc = new Scanner(System.in);
int count = 0; // 记录不能被5整除的数的个数
for(int i = 1; i <= 100 ; i++){
if(i % 5 != 0){
System.out.print(i + " ");
count++;
if(count % 5 == 0){
System.out.println("\n");
}
}
}
}
}
class HomeWork05{
public static void main(String[] args){
//输出小写的 a - z
for(char a = 97 ; a <= 'z' ; a++){
System.out.print(a + " ");
}
//换行
System.out.println("");
//输出大写的 A - Z
for(char a = 65 ; a <= 'Z' ; a++){
System.out.print(a + " ");
}
}
}
class HomeWork06{
public static void main(String[] args){
// 1 - 1 / 2 + 1 / 3 - 1 / 4 ... 1 / 100 的和
double sum = 0.0;
for(int i = 1 ; i <= 100 ; i++){
sum += Math.pow(-1 , i - 1) * 1 / i;
}
System.out.println(sum);
}
}
class HomeWork07{
public static void main(String[] args){
// 求 1 + ( 1 + 2) + ( 1 + 2 + 3) + ... + ( 1 + 2 + ... + 100) 的和
int sum = 0;
for(int i = 1 ; i <= 100 ; i++){
for(int j = 1 ; j <= i ; j++){
sum += j;
}
}
System.out.println(sum);
}
}