真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java代碼練習(xí)題 java編程代碼題庫及答案

java練習(xí)題求解希望有完整代碼

運行代碼

我們提供的服務(wù)有:成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、正寧ssl等。為超過千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的正寧網(wǎng)站制作公司

具體的代碼如下:

import java.util.HashMap;

public class SearchDemo {

public HashMapInteger,Integer countMap(char[] arr){

HashMap countMap = new HashMapInteger, Integer();

for (int i = 0; i arr.length; i++) {

if(!countMap.containsKey(arr[i])){

countMap.put(arr[i],1);

}else{

int value = (int)countMap.get(arr[i]) + 1;

countMap.put(arr[i],value);

}

}

return countMap;

}

public static void main(String[] args) {

char[] arr={'A','1','R','!','e','','A','5','A','g','#','D'};

int count = new SearchDemo().countMap(arr).get('A');

System.out.println("其中'A'字符的個數(shù)是:" + count);

}

}

運行結(jié)果

java練習(xí)題求完整代碼

按照題目要求編寫的用javaBean規(guī)范設(shè)計的學(xué)生類Student的Java程序如下

需要創(chuàng)建user.java.test包,把Student.java文件和Test.java文件放入包中,編譯Student.java文件并且編譯運行Test.java文件得到運行結(jié)果

Student.java文件代碼如下

package user.java.test;

import java.io.Serializable;

public class Student implements Serializable{

private static final long serialVersionUID = 1L;

private String no;

private String name;

private double score;

public Student(){}

public Student(String no,String name,double score){

this.no=no;

this.name=name;

this.score=score;

}

public String getNo(){ return no;}

public void setNo(String no){ this.no=no;}

public String getName(){ return name;}

public void setName(String name){ this.name=name;}

public double getScore(){ return score;}

public void setScore(double score){ this.score=score;}

public String toString(){

return "學(xué)號:"+no+",姓名:"+name+",成績:"+score;

}

public static double getAvg(Student[] sArray){

double sum=0,avg;

for(int i=0;isArray.length;i++){

sum=sum+sArray[i].getScore();

}

avg=sum/sArray.length;

return avg;

}

}

Test.java文件代碼如下

package user.java.test;

public class Test{

public static void main(String[] args){

Student[] sArray=new Student[5];

sArray[0]=new Student("001","張三",89.5);

sArray[1]=new Student("002","李四",82.5);

sArray[2]=new Student("003","王五",93);

sArray[3]=new Student("004","趙六",73.5);

sArray[4]=new Student("005","孫七",66);

System.out.println("這些學(xué)生的平均分:"+Student.getAvg(sArray));

for(int i=0;isArray.length;i++){

System.out.println(sArray[i].toString());

}

}

}

JAVA 練習(xí)題

public class JavaExos {

public static void charInt(String chaine){ //1044

String[] charInt = new String[2];

int count = -1;

char maxChar = 'A';

int[] letterCount = new int[26];

String word = chaine.toLowerCase();

for (int i=0;iword.length();i++) {

int indexOfChar = (byte)word.charAt(i)-97;

letterCount[indexOfChar]++;

if (letterCount[indexOfChar]count || (letterCount[indexOfChar]==count word.charAt(i)maxChar)){

count = letterCount[indexOfChar];

maxChar = word.charAt(i);

}

}

charInt[0] = String.valueOf(maxChar);

charInt[1] = ""+count;

System.out.println(charInt[0]+" "+charInt[1]);

}

public static void getDate(int n){ //1047 這題如果給1,其實是指2000年1月2號.

n++;

int[] getYear = getYear(n);

int year = getYear[0];

int[] getMonth = getMonth(year,getYear[1]);

int month = getMonth[0];

String monthString ;

if(month10) monthString = "0"+String.valueOf(month);

else monthString = String.valueOf(month);

int day = getMonth[1];

System.out.println(year+"-"+monthString+"-"+day+" "+getDayOfWeek(n));

}

private static boolean isBissextile(int n){

if (n%4==0 !(n%100==0n%400!=0))

return true;

else

return false;

}

private static int[] getYear(int n){

int[] getYear = new int[2];

int year = 2000;

while(n0){

if(isBissextile(year)) n -= 366;

else n -= 365;

if (n0) year++;

}

if(isBissextile(year)) n+=366;

else n += 365;

getYear[0] = year;

getYear[1] = n;

return getYear;

}

private static int[] getMonth(int year, int n){

int[] getMonth = new int[2];

int month = 1;

while(n0){

if(month=7 month%2 != 0) n -= 31;

else if (month==2 isBissextile(year) ) n -= 29;

else if (month==2 !isBissextile(year)) n -= 28;

else if(month=7 month%2==0) n -= 30;

else if(month%2==0) n-=31;

else n -= 30;

if (n0) month++;

}

if(month=7 month%2 != 0) n += 31;

else if (isBissextile(year) month==2) n += 29;

else if (!isBissextile(year) month==2) n += 28;

else if(month=7 month%2==0) n += 30;

else if(month%2==0) n+=31;

else n += 30;

getMonth[0] = month;

getMonth[1] = n;

return getMonth;

}

private static String getDayOfWeek(int n){

int quotient = n/7;

int remainder = n -= quotient*7;

switch(remainder){

case 0 : return "Sunday";

case 1 : return "Monday";

case 2 : return "Tuesday";

case 3 : return "Wednesday";

case 4 : return "Thursday";

case 5 : return "Friday";

case 6 : return "Saturday";

default : return "Never arrive";

}

}

public static void getCode(String chaine){ //1048

chaine = chaine.toUpperCase();

System.out.println("START");

System.out.println(chaine);

System.out.println("END");

System.out.println();

for(int i=0;ichaine.length();i++){

System.out.print((changChar(chaine.charAt(i))));

}

System.out.println();

}

private static char changChar(char c){

if(c=65 c=90 c-565) return (char)(c+26-5);

else if(c=65 c=90) return (char)(c-5);

else return c;

}

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

JavaExos.charInt("adfadffasdfda");

JavaExos.getDate(1751);

JavaExos.getCode("NS BFW, JAJSYX TK NRUTWYFSHJ FWJ YMJ WJXZQY TK YWNANFQ HFZXJX");

java練習(xí)題求大神剛學(xué)

按照題目要求編寫的商品類Item的Java程序如下

public class Item{

public String code,name,type;

public double price;

public static int totalNum=0;

public Item(){}

public Item(String code,String name){

this.code=code;

this.name=name;

totalNum++;

}

public static void main(String[] args){

Item[] item=new Item[10];

item[0]=new Item("666","戴爾(DELL) 游戲筆記本");

item[0].type="游戲";item[0].price=5499.00;

item[1]=new Item("007","蘋果(Macbook pro)筆記本");

item[1].type="電腦,辦公";item[1].price=18000.00;

for(int i=0;iItem.totalNum;i++){

System.out.println("名稱:"+item[i].name+",價格:"+item[i].price);

}

System.out.println("總商品數(shù)量:"+Item.totalNum);

}

}


網(wǎng)頁題目:java代碼練習(xí)題 java編程代碼題庫及答案
網(wǎng)站鏈接:http://weahome.cn/article/ddigccj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部