Posts

Showing posts from November, 2009

Program 8 :: LeapYear

// Program :: Write a Java Program to finding the LeapYear import java.io.*; public class LeapYear { public static boolean isLeapYear(int year) { if( year % 4 != 0 ){ return false; } if(( year % 400 != 0 ) && (year % 100 == 0)){ return false; }else{ return true; } } public static void main (String[] args){ int year = 0; String input = ""; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); while(true){ System.out.println("Enter the year: "); try { input = in.readLine(); year = Integer.valueOf( input ).intValue(); } catch (IOException e) { e.printStackTrace(); } if(year < 0){break;} System.out.print ("Is it a leap year? "); System.out.println( isLeapYear(year) ); } } } // Engr. Parag Ferdus 01713 400 421, 01914 949 399, 01670 876 388 // www.pfbd.yolasite.com paragferdus@gmail.com

Program 7:: Max and Min

// Program 7:: Write a Program to find max and min of two integer // import java.io.*; class min_max { public static void main(String args[]) { DataInputStream in=new DataInputStream(System.in); int a=0; int b=0; int c=0; try { System.out.print("Enter 1st number="); a = Integer.parseInt(in.readLine()); System.out.print("Enter 2nd number="); b = Integer.parseInt(in.readLine()); } catch(Exception e){} c=(a>b?a:b); System.out.println("Maximum number is="+c); c=(a System.out.println("Minimum number is="+c); } } // Engr. Parag Ferdus 01713 400 421, 01914 949 399, 01670 876 388 // www.pfbd.yolasite.com paragferdus@gmail.com