第6周作业

来源:互联网 发布:菠萝饭官方软件 编辑:程序博客网 时间:2024/04/30 19:57

//1-闰年之循环判断

package ww;//闰年程序public class LeapYearFor2 {static boolean isLeapYear(int year){if((year%4==0&&year%100!=0)||year%400==0)return true;elsereturn 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级");elseif(score<70)JOptionPane.showMessageDialog(null, "C级");elseif(score<85)JOptionPane.showMessageDialog(null, "B级");elseJOptionPane.showMessageDialog(null, "A级");}}




0 0
原创粉丝点击