Question: Analyse the quality of the Java codes below public static boolean leap(int y) { String tmp = String.valueOf(y); if (tmp.charAt(2) == '1' || tmp.charAt(2) ==
Analyse the quality of the Java codes below
public static boolean leap(int y) { String tmp = String.valueOf(y); if (tmp.charAt(2) == '1' || tmp.charAt(2) == '3' || tmp.charAt(2) == 5 || tmp.charAt(2) == '7' || tmp.charAt(2) == '9') { if (tmp.charAt(3)=='2'||tmp.charAt(3)=='6') return true; /*R1*/ else return false; /*R2*/ }else{ if (tmp.charAt(2) == '0' && tmp.charAt(3) == '0') { return false; /*R3*/ } if (tmp.charAt(3)=='0'||tmp.charAt(3)=='4'||tmp.charAt(3)=='8')ret urn true; /*R4*/ } return false; /*R5*/ }
Step by Step Solution
There are 3 Steps involved in it
Answer The Java code provided is a method named leap that checks whether a given year y is a leap ye... View full answer
Get step-by-step solutions from verified subject matter experts
