//1-闰年之循环判断
package ww;
//闰年程序
public class LeapYearFor2 {
static boolean isLeapYear(int year){
if((year%4==0&&year%100!=0)||year%400==0)
return true;
else
return false;
}
public static void main(String args[]){
int count=0;
for(int i=1800;i<=2014;i++){
if(isLeapYear(i)){
System.out.print(" "+i);
count++;
}
if(count%25==0)
System.out.println();
}
}
}
运行结果如下
1804 1808 1812 1816 1820 1824 1828 1832 1836 1840 1844 1848 1852 1856 1860 1864 1868 1872 1876 1880 1884 1888 1892 1896 1904
1908 1912 1916 1920 1924 1928 1932 1936 1940 1944 1948 1952 1956 1960 1964 1968 1972 1976 1980 1984 1988 1992 1996 2000 2004
2008 2012
// 2-IF语句大显身手之成绩判断
import javax.swing.JOptionPane;
public class GradeIf2 {
public static void main(String args[])
{
double grade = 0.0;
double score = 0;
String input = JOptionPane.showInputDialog("Enter the grade of a TouchType: ");
score=new Integer(input);
System.out.println(score );
if(score<60)
JOptionPane.showMessageDialog(null, "D级");
else
if(score<70)
JOptionPane.showMessageDialog(null, "C级");
else
if(score<85)
JOptionPane.showMessageDialog(null, "B级");
else
JOptionPane.showMessageDialog(null, "A级");
}
}