JAVA 练习题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]==countword.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;
elsen -= 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=7month%2 != 0)n -= 31;
else if (month==2isBissextile(year)) n -= 29;
else if (month==2!isBissextile(year)) n -= 28;
else if(month=7month%2==0) n -= 30;
else if(month%2==0) n-=31;
else n -= 30;
if (n0)month++;
}
if(month=7month%2 != 0)n += 31;
else if (isBissextile(year)month==2) n += 29;
else if (!isBissextile(year)month==2) n += 28;
else if(month=7month%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=65c=90c-565)return (char)(c+26-5);
else if(c=65c=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练习题求大神刚学按照题目要求编写java初学者代码练习题的商品类Itemjava初学者代码练习题的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){
推荐阅读
- 你的电脑末正确起什么原因,你的电脑未正确启动的解决办法
- Mysql唯一索引长度,mysql索引长度计算
- 家族信托如何营销,家族信托营销案例分享
- 直播带货必须开小店嘛,直播带货必须开小店嘛知乎
- python3.7函数 python函数详解
- 点赞视频号怎么能朋友看到,好友视频号点赞
- ss下载,boss下载
- 抖音直播带货威胁分析,抖音直播带货存在的问题及对策研究论文
- go语言和groovy Go语言和Rust