/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package leapyear; /** * * @author jcmtiernan */ public class LeapYear { /** * @param args the command line arguments */ public static void main(String[] args) { int year; boolean leap = false; year = 1700; /* Use the algorithm below to determine if the year is a common year or a leap year and then print a message to the user telling what type of year it is. Leap year algorithm: if (year is not exactly divisible by 4) then (it is a common year) else if (year is not exactly divisible by 100) then (it is a leap year) else if (year is not exactly divisible by 400) then (it is a common year) else (it is a leap year) * Use the boolean value leap to record if the year is a leap year or not */ int iDiv, iDiv2, iRem, iRem2, iRem3; double dDiv, dDiv2; iDiv = year / 4; dDiv = year / 4.0; iDiv2 = year /400; dDiv2 = year / 400.0; iRem = year % 4; iRem2 = year % 100; iRem3 = year % 400; /* if (iRem != 0) //(dDiv != iDiv) // { leap = false; } else if (iRem2 != 0) //((year /100) != (year / 100.0)) { leap = true; } else if (iRem3 != 0) //(dDiv2 != iDiv2) { leap = false; } else { leap = true; } System.out.println("Your year "+year+" is "+(leap?"":"NOT") +" a leap year"); */ /* Seperate years into "No writing before 150", "Runic 150" , "Alphabetic writing 800", "printing press 1440", "typewriter 1808", "computer 1940" */ year = 2015; if (year < 150) { year = 150; } else if (year < 800) //(year >= 150) { year = 800; } else if (year < 1440) { year = 1440; } else if (year < 1808) { year = 1808; } else if (year < 1940) { year = 1940; } else if (year < 2016) { year = 2016; } else { year = 2017; } switch(year) { case 150: System.out.println("Year "+year+" has no recorded writings"); break; case 800 : System.out.println("Year "+year+" has runic writings"); System.out.println("a second line"); break; case 1440 : System.out.println("Year "+year+" has alphabtic writings"); break; case 1808 : System.out.println("Year "+year+" has printing presses"); break; case 1940 : System.out.println("Year "+year+" has typewriters"); break; case 2016 : case 2017 : System.out.println("Year "+year+" has computers"); break; default : System.out.println("Year "+year+" has SOMETHING"); break; } char c = 'B'; switch(c) { case 'A': case 'a': System.out.println("case A"); break; case 'B': case 'b': System.out.println("case b"); break; default : System.out.println("not 150"); break; } } }