欢迎来到天天文库
浏览记录
ID:37923007
大小:127.50 KB
页数:18页
时间:2019-06-02
《Java 基础题目集锦》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Java基础题目集锦【本人自己对照树上的问题进行的解答,】【1】importjava.util.Scanner;publicclassAdd{publicstaticvoidmain(String[]args){finalintNUM=10;System.out.println("***********************************************************");System.out.println("t欢迎使用加法测试小游戏");System.out.println();System.out.println("====
2、====================================================");System.out.println("Let'sBegin:");System.out.println("——————");System.out.println("请选择加法范围:[0]--10以内t[1]--100以内t[2]--1000以内");Scannerscan=newScanner(System.in);intflag;flag=scan.nextInt();intGO=10;while(flag<0
3、
4、flag>3){System.o
5、ut.print("请重新选择加法范围:");flag=scan.nextInt();}switch(flag){case0:GO=10;break;case1:GO=100;break;default:GO=1000;}intcount1=0,count2=0;intc;while(count1+count26、{System.out.println("WellDone!");count1++;}else{System.out.println("YouNeedMorePractice");count2++;}}System.out.println("YourGradesAre:"+(count1*10-count2*10));switch(count1){case10:System.out.println("YouAreSoClever");break;case9:System.out.println("YouAreExclent");break;case8:Syste7、m.out.println("YouAreHardworking");break;case7:System.out.println("YouAreGood");break;case6:System.out.println("YouNeedWordHard");break;default:System.out.println("YoushouldStudyHard");}System.out.println("TranksForUsing.....");}}888888888888888888888888888888888888888888888888888888888、88888888888888888888888【2】importjava.util.Scanner;//importjava.swing.JFrame;importjava.util.Random;publicclassaverage{publicstaticvoidmain(String[]args){inta,b,c;/*Scannerscan=newScanner(System.in);System.out.print("Entera:");a=scan.nextInt();System.out.print("Enterb:");b=scan.nextInt(9、);System.out.print("Enterc:");c=scan.nextInt();doubleave=(a+b+c)/3.0;System.out.println("ave="+ave);System.out.println("HelloWorld!");Stringphrase="Changeisinevitable";Stringm1,m2,m3,m4,m5;booleant1,t2;charc1;ints;System.out.println("Originalstring:"+phrase);System.out.println("L
6、{System.out.println("WellDone!");count1++;}else{System.out.println("YouNeedMorePractice");count2++;}}System.out.println("YourGradesAre:"+(count1*10-count2*10));switch(count1){case10:System.out.println("YouAreSoClever");break;case9:System.out.println("YouAreExclent");break;case8:Syste
7、m.out.println("YouAreHardworking");break;case7:System.out.println("YouAreGood");break;case6:System.out.println("YouNeedWordHard");break;default:System.out.println("YoushouldStudyHard");}System.out.println("TranksForUsing.....");}}88888888888888888888888888888888888888888888888888888888
8、88888888888888888888888【2】importjava.util.Scanner;//importjava.swing.JFrame;importjava.util.Random;publicclassaverage{publicstaticvoidmain(String[]args){inta,b,c;/*Scannerscan=newScanner(System.in);System.out.print("Entera:");a=scan.nextInt();System.out.print("Enterb:");b=scan.nextInt(
9、);System.out.print("Enterc:");c=scan.nextInt();doubleave=(a+b+c)/3.0;System.out.println("ave="+ave);System.out.println("HelloWorld!");Stringphrase="Changeisinevitable";Stringm1,m2,m3,m4,m5;booleant1,t2;charc1;ints;System.out.println("Originalstring:"+phrase);System.out.println("L
此文档下载收益归作者所有