1 / 9

1 输入一个年份,输出是否闰年。 2 键盘输入一个数,判断是否偶数? 3 输入工资数,然后计算个人所得税。 0-2000 税率 0 , 2000-2500 税率 5%

1 输入一个年份,输出是否闰年。 2 键盘输入一个数,判断是否偶数? 3 输入工资数,然后计算个人所得税。 0-2000 税率 0 , 2000-2500 税率 5% 2500-4000 税率 10%,4000-6000 税率 20% 6000-8000 税率 30% 4 输入一个分数,输出对应的成绩等第 (5 级 ) 。( switch , if 两种方法实现 ). 6 改错 public class test1 { public static void main(String[] args) { int a=3;

serena
Télécharger la présentation

1 输入一个年份,输出是否闰年。 2 键盘输入一个数,判断是否偶数? 3 输入工资数,然后计算个人所得税。 0-2000 税率 0 , 2000-2500 税率 5%

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 1 输入一个年份,输出是否闰年。 2 键盘输入一个数,判断是否偶数? 3 输入工资数,然后计算个人所得税。 0-2000 税率0,2000-2500税率5% 2500-4000税率10%,4000-6000税率20% 6000-8000税率30% 4 输入一个分数,输出对应的成绩等第(5级)。(switch , if 两种方法实现)

  2. 6 改错 public class test1 { public static void main(String[] args) { int a=3; float b=4.1f; switch( b ){ case a>b: System.out.println(“小于"); case 4.1: System.out.println(“等于"); } } }

  3. 循环

  4. 1 从键盘输入整数 n,输出 n! . 2 1!+2!+3! +…. + 10! (将阶乘作为一个方法) 3 求3-100间的素数 4 打印如下图案:行数 n 有可变 * * * * * * * * * * * * * 5. 输出乘法口诀表 1*1=1 2*1=2 2*2=4 3*1=3 3*2=6 3*3=9 4*1=4 4*2=8 4*3=12 4*4=16 5*1=5 5*2=10 5*3=15 5*4=20 5*5=25 ….

  5. 练习 JDB 调试程序。 完成设置断点、查看当前变量值、查看当前运行代码、执行下一行代码。 public class jdbTest { static long fact ( int n) { long m=1; int i = 0; while ( i<n ) { i ++ ; m = m * i ; } return m; } public static void main( String args[]){ int n =10 ; long nFact ; nFact = fact ( n ) ; System.out.println( n+" 的阶乘为:"+nFact ); } }

  6. 日期相关 1 编写一个计算闰年的方法, 传入参数:年份 返回值:true 表示闰年 false 表示非闰年 1)写出完整的程序,测试该方法 2)练习调试功能 2 编写一个计算某日期是星期几的方法 getWeek。(已知1980.1.1 为星期二) 传入参数:年、月、日 返回值:星期几 (0:星期天 1 星期一…) 请利用getWeek 计算 2009年10月1日是星期几? getWeek( 2009,10,1) 3编写一个计算某日期的方法 nextDay。 传入参数:年、月、日 ,天数 n ( n为负 计算该天之前的日期), 返回值:n天后的日期 请利用nextDay 计算 2009年12月28日,9天后的日期。 netDay( 2009,12,28 , 9) 4编写一个两日期之间天数的方法 getDays。 传入参数:年1、月1、日1 ,年2、月2、日2 返回值:天数 请利用getDays 计算 2010年5月1日于2005年10月31日之间的天数。

  7. float nSalary , nTax=0; String sInput; InputStreamReader ir = new InputStreamReader (System.in); BufferedReader br = new BufferedReader(ir); try { sInput = br.readLine(); nSalary = Float.parseFloat( sInput) ; if (nSalary<2000) nTax = 0; else if (nSalary>2000 && nSalary<=2500) nTax = (nSalary - 2000) * 0.05f ; else if (nSalary>2500 && nSalary<=4000) nTax = (nSalary - 2500) * 0.10f + 500 * 0.05f; else if (nSalary>4000 && nSalary<=6000) nTax = (nSalary - 4000) * 0.20f + 1500*0.1f+500 * 0.05f; else if (nSalary>6000 && nSalary<=8000) nTax = (nSalary-6000)*0.30f+2000*0.2f+1500*0.1f+500* 0.05f; else nTax = (nSalary - 8000) * 0.45f + 2000*0.3f+2000*0.2f+1500*0.1f+500 * 0.05f; System.out.println(nTax); }catch( IOException ee ){};

  8. double nData , nInput; String sInput; InputStreamReader ir = new InputStreamReader (System.in); BufferedReader br = new BufferedReader(ir); nData = Math.random() * 100 ; try { for (int i=1;i<=3;i++) { System.out.println("please input data:"); sInput = br.readLine(); nInput = Double.parseDouble( sInput) ; if (nInput>nData) System.out.println("大"); else if (nInput<nData) System.out.println("小"); else { System.out.println("恭喜"); break; } } }catch( IOException ee ){}; System.out.println("Random Data:"+nData);

  9. for(int i=1;i<=9;i++){ for(int j=1;j<=i;j++) System.out.print(j+"*"+i+"="+(i*j)+" " ); System.out.println(); } for(int i=1;i<=9;i++){ for(int j=1;j<=i;j++){ System.out.print(j+"*"+i+"="+(i*j) ); if (i*j>9) System.out.print(" "); else System.out.print(" "); } System.out.println(); }

More Related