import java.util.Scanner; public class Driver { public static void main2(String [] args) { Scanner in = new Scanner(System.in); String s = in.nextLine(); int n = in.nextInt(); double d = in.nextDouble(); System.out.println(s); System.out.println(n); System.out.println(d); /* n = in.nextInt(); s = in.nextLine(); d = in.nextDouble(); System.out.println(s); System.out.println(n); System.out.println(d); */ } public static void main4(String [] args) { Scanner in = new Scanner(System.in); System.out.println("Enter values for n, d, and b"); int n = in.nextInt(); double d = in.nextDouble(); byte b = in.nextByte(); System.out.format("n = %d%nd = %f%nb = %b", n, d, b); } public static void main6(String [] args) { double x = 2.0 / 3.0; System.out.format( "x = %4.3f", x ); } public static void main3(String [] args) { double x = 2.0 / 3.0; char c = 'd'; int y = 777; System.out.format( "x = %4.2f%c%4d%n", x, c, y ); } public static void main(String [] args) { //get user input Scanner in = new Scanner(System.in); System.out.println("What is the year? >"); int year = in.nextInt(); System.out.println("year = " + year); //print is a leap year or not if(isLeapYear(year)) { System.out.println("THIS IS A LEAP YEAR"); } else { System.out.println("common year..."); } } public static boolean isLeapYear(int year) { //https://en.wikipedia.org/wiki/Leap_year /* * if (year is not divisible by 4) then (it is a common year) * else if (year is not divisible by 400) then (it is a common year) * else (it is a leap year) */ System.out.println("year % 4 = " + (year % 4)); System.out.println("year % 400 = " + (year % 400)); if(year % 4 != 0) { return false; } else if(year % 400 == 0) { return true; } else if(year % 100 == 0) { return false; } else { return true; } } }