資源描述:
《java程序代碼》由會(huì)員上傳分享,免費(fèi)在線(xiàn)閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、1.importjava.util.*;publicclasschap{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);System.out.println("請(qǐng)輸入個(gè)人信息");System.out.print("姓名:");Stringname=input.next();System.out.print("年齡:");intage=input.nextInt();System.out.print("性別:");Stringsex=input.next();Syst
2、em.out.print("身高:");doubleheigh=input.nextDouble();System.out.print("家庭住址:");Stringadress=input.next();System.out.println("------------------------------");System.out.println("您的個(gè)人信息:");System.out.println("姓名:"+name);System.out.println("年齡:"+age);System.out.println("性別:"+sex)
3、;System.out.println("身高:"+heigh);System.out.println("家庭住址:"+adress);}}2.importjava.util.*;publicclasschap1{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);System.out.println("************************************");System.out.println("*xx超市歡迎您!*");System.ou
4、t.println("************************************");System.out.print("請(qǐng)輸入會(huì)員卡號(hào):");Stringnumber=input.next();System.out.print("請(qǐng)輸入消費(fèi)金額:");doublecount=input.nextDouble();System.out.print("請(qǐng)輸入付款金額:");doublecash=input.nextDouble();System.out.print("您的會(huì)員卡號(hào)為:");System.out.println(number);Sy
5、stem.out.print("找零:");doublechage=(cash-count);System.out.println(chage);System.out.println("本次積分:"+count/100*3);System.out.println("------------------------------------");System.out.println("歡迎再次光臨!");}}3.輸出棱形publicclasschap2{publicstaticvoidmain(String[]args){intn=6;for(inti=1;i<
6、=n;i++){for(intk=n-1;k>=i;k--){System.out.print("");}for(intj=1;j<=2*i-1;j++){System.out.print("*");}System.out.println();}for(inti=n-1;i>=1;i--){for(intk=i;k<=n-1;k++){System.out.print("");}for(intj=1;j<=2*i-1;j++){System.out.print("*");}System.out.println();}}}4.查找數(shù)組中的數(shù)importjava
7、.util.*;publicclasschap21{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);int[]array={9,12,17,19,21,24,38,42,56,78};for(inti=0;i<=9;i++){System.out.println("array"+"["+i+"]="+array[i]);}System.out.println("請(qǐng)輸入數(shù)組中要查找的數(shù):");inta=input.nextInt();inttarget=a;intind
8、ex=0;intstart=0;intend=arr