import java.io.BufferedReader;
成都创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站建设、网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的武穴网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
import java.io.InputStreamReader;
public class TT {
/**
* @param args
*/
public static void main(String[] args) {
int R = -1;
int G = -1;
int B = -1;
while ( true ) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = null;
System.out.println("Enter R value:");
str = br.readLine();
R = Integer.parseInt(str);
if (R!=-1 (R = 0 R =255)) {
System.out.println("The R value is :"+R);
break;
} else
System.out.println("please input valid INTEGER value and value should between 0 ~ 255");
} catch(Exception e) {
System.out.println("please input valid INTEGER value and value should between 0 ~ 255");
}
}
while ( true ) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = null;
System.out.println("Enter G value:");
str = br.readLine();
G = Integer.parseInt(str);
if (G!=-1 (G = 0 G =255)) {
System.out.println("The G value is :"+G);
break;
} else
System.out.println("please input valid INTEGER value and value should between 0 ~ 255");
} catch(Exception e) {
System.out.println("please input valid INTEGER value and value should between 0 ~ 255");
}
}
while ( true ) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = null;
System.out.println("Enter B value:");
str = br.readLine();
B = Integer.parseInt(str);
if (B!=-1 (B = 0 B =255)) {
System.out.println("The B value is :"+B);
break;
} else
System.out.println("please input valid INTEGER value and value should between 0 ~ 255");
} catch(Exception e) {
System.out.println("please input valid INTEGER value and value should between 0 ~ 255");
}
}
String[] h=new String[256];
h[0]="00";h[1]="01";h[2]="02";h[3]="03";h[4]="04";h[5]="05";
h[6]="06";h[7]="07";h[8]="08";h[9]="09";h[10]="0A";h[11]="0B";
h[12]="0C";h[13]="0D";h[14]="0E";h[15]="0F";h[16]="10";h[17]="11";
h[18]="12";h[19]="13";h[20]="14";h[21]="15";h[22]="16";h[23]="17";
h[24]="18";h[25]="19";h[26]="1A";h[27]="1B";h[28]="1C";h[29]="1D";
h[30]="1E";h[31]="1F";h[32]="20";h[33]="21";h[34]="22";h[35]="23";
h[36]="24";h[37]="25";h[38]="26";h[39]="27";h[40]="28";h[41]="29";
h[42]="2A";h[43]="2B";h[44]="2C";h[45]="2D";h[46]="2E";h[47]="2F";
h[48]="30";h[49]="31";h[50]="32";h[51]="33";h[52]="34";h[53]="35";
h[54]="36";h[55]="37";h[56]="38";h[57]="39";h[58]="3A";h[59]="3B";
h[60]="3C";h[61]="3D";h[62]="3E";h[63]="3F";h[64]="40";h[65]="41";
h[66]="42";h[67]="43";h[68]="44";h[69]="45";h[70]="46";h[71]="47";
h[72]="48";h[73]="49";h[74]="4A";h[75]="4B";h[76]="4C";h[77]="4D";
h[78]="4E";h[79]="4F";h[80]="50";h[81]="51";h[82]="52";h[83]="53";
h[84]="54";h[85]="55";h[86]="56";h[87]="57";h[88]="58";h[89]="59";
h[90]="5A";h[91]="5B";h[92]="5C";h[93]="5D";h[94]="5E";h[95]="6F";
h[96]="60";h[97]="61";h[98]="62";h[99]="63";h[100]="64";h[101]="65";
h[102]="66";h[103]="67";h[104]="68";h[105]="69";h[106]="6A";h[107]="6B";
h[108]="6C";h[109]="6D";h[110]="6E";h[111]="6F";h[112]="70";h[113]="71";
h[114]="72";h[115]="73";h[116]="74";h[117]="75";h[118]="76";h[119]="77";
h[120]="78";h[121]="79";h[122]="7A";h[123]="7B";h[124]="7C";h[125]="7D";
h[126]="7E";h[127]="7F";h[128]="80";h[129]="81";h[130]="82";h[131]="83";
h[132]="84";h[133]="85";h[134]="86";h[135]="87";h[136]="88";h[137]="89";
h[138]="8A";h[139]="8B";h[140]="8C";h[141]="8D";h[142]="8E";h[143]="8F";
h[144]="90";h[145]="91";h[146]="92";h[147]="93";h[148]="94";h[149]="95";
h[150]="96";h[151]="97";h[152]="98";h[153]="99";h[154]="9A";h[155]="9B";
h[156]="9C";h[157]="9D";h[158]="9E";h[159]="9F";h[160]="A0";h[161]="A1";
h[162]="A2";h[163]="A3";h[164]="A4";h[165]="A5";h[166]="A6";h[167]="A7";
h[168]="A8";h[169]="A9";h[170]="AA";h[171]="AB";h[172]="AC";h[173]="AD";
h[174]="AE";h[175]="AF";h[176]="B0";h[177]="B1";h[178]="B2";h[179]="B3";
h[180]="B4";h[181]="B5";h[182]="B6";h[183]="B7";h[184]="B8";h[185]="B9";
h[186]="BA";h[187]="BB";h[188]="BC";h[189]="BD";h[190]="BE";h[191]="BF";
h[192]="C0";h[193]="C1";h[194]="C2";h[195]="C3";h[196]="C4";h[197]="C5";
h[198]="C6";h[199]="C7";h[200]="C8";h[201]="C9";h[202]="CA";h[203]="CB";
h[204]="CC";h[205]="CD";h[206]="CE";h[207]="CF";h[208]="D0";h[209]="D1";
h[210]="D2";h[211]="D3";h[212]="D4";h[213]="D5";h[214]="D6";h[215]="D7";
h[216]="D8";h[217]="D9";h[218]="DA";h[219]="DB";h[220]="DC";h[221]="DD";
h[222]="DE";h[223]="DF";h[224]="E0";h[225]="E1";h[226]="E2";h[227]="E3";
h[228]="E4";h[229]="E5";h[230]="E6";h[231]="E7";h[232]="E8";h[233]="E9";
h[234]="EA";h[235]="EB";h[236]="EC";h[237]="ED";h[238]="EE";h[239]="EF";
h[240]="F0";h[241]="F1";h[242]="F2";h[243]="F3";h[244]="F4";h[245]="F5";
h[246]="F6";h[247]="F7";h[248]="F8";h[249]="F9";h[250]="FA";h[251]="FB";
h[252]="FC";h[253]="FD";h[254]="FE";h[255]="FF";
String B16 = "#" + h[R] + h[G] + h[B];
System.out.println(B16);
}
}
import java.util.*;/**规则在这里 超过字数了 我吧缩进删了*/public class SolarTerm {public static void main(String[] s) throws Exception{SolarTerm st = new SolarTerm();if(s.length == 3){System.out.println(st.getSoralTerm(Integer.parseInt(s[0]), Integer.parseInt(s[1]), Integer.parseInt(s[2])));}System.out.println(st.getSoralTerm(2009, 1, 5));System.out.println(st.getSoralTerm(2009, 1, 20));System.out.println(st.getSoralTerm(2009, 1, 23));System.out.println(st.getSoralTerm(2009, 2, 18));}final static long[] STermInfo = new long[] { 0, 21208, 42467, 63836, 85337,107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343,285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795,462224, 483532, 504758 };private static final String[] SolarTerm = new String[] { "小寒", "大寒", "立春", "雨水","惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋","处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"};public SolarTerm(){}/** 核心方法 根据日期得到节气 */public String getSoralTerm(Date Date){Calendar cal = Calendar.getInstance();cal.setTime(Date);int y = cal.get(Calendar.YEAR);int m = cal.get(Calendar.MONTH) + 1;int d = cal.get(Calendar.DAY_OF_MONTH);return getSoralTerm(y, m, d);}/** 核心方法 根据日期(y年m月d日)得到节气 */public String getSoralTerm(int y, int m, int d){String solarTerms;if (d == sTerm(y, (m - 1) * 2)) solarTerms = SolarTerm[(m - 1) * 2];else if (d == sTerm(y, (m - 1) * 2 + 1)) solarTerms = SolarTerm[(m - 1) * 2 + 1];else{//到这里说明非节气时间 solarTerms = "";}return solarTerms;}// ===== y年的第n个节气为几日(从0小寒起算)private int sTerm(int y, int n) {Calendar cal = Calendar.getInstance();cal.set(1900, 0, 6, 2, 5, 0);long temp = cal.getTime().getTime();cal.setTime(new Date( (long) ((31556925974.7 * (y - 1900) + STermInfo[n] * 60000L) + temp)));return cal.get(Calendar.DAY_OF_MONTH);}}
当执行2*3时,首先resustNum=2,这是在点击*时,获取的文本框的值。然后点击等号时,触发乘法运算:代码如下:
//乘法运算
resultNum *= getNumberFromText();
此时调用getNumberFromText()方法。
private double getNumberFromText(){
double result = 0;
try {
result = Double.valueOf(resultText.getText()).doubleValue();
} catch (NumberFormatException e){
}
return result;
}
返回当前文本框的值,所以现在resustNum就是结果的值。
彩色部分:
else if (operator.equals("=")){//这段代码就是说在点击=号之前,没有点击任何操作符。
//赋值运算
resultNum = getNumberFromText();
}
if (operateValidFlag) {
//双精度浮点数的运算
long t1;
double t2;//这个就是判断运算是否损失精度,要输出的是long型的。
t1 = (long) resultNum;
t2 = resultNum - t1;
if (t2 == 0) {
resultText.setText(String.valueOf(t1));
} else {
resultText.setText(String.valueOf(resultNum));
}
}
本文实例讲述了JavaScript实现彩虹文字效果的方法。分享给大家供大家参考。具体如下:
HTML
HEAD
TITLERainbow Text/TITLE
[removed]
!-- Begin hide from old browsers
function createHexArray(n)
{
this.length = n;
for (var i = 1; i = n; i++)
this[i] = i - 1;
this[11] = "A";
this[12] = "B";
this[13] = "C";