Commit 591e6deb authored by Suresh Kumar's avatar Suresh Kumar

update

parent fd2d9a7d
package com.task1; package com.task1;
import java.util.Scanner; import java.util.Scanner;
public class StringValidity { public class StringValidity {
public static void main(String[] args) { public static void main(String[] args) {
...@@ -7,22 +9,21 @@ public class StringValidity { ...@@ -7,22 +9,21 @@ public class StringValidity {
Scanner sc = new Scanner(System.in); Scanner sc = new Scanner(System.in);
System.out.print("Enter A Name .. "); System.out.print("Enter A Name .. ");
String name = sc.nextLine(); String name = sc.nextLine();
boolean isValid=true; boolean isValid = true;
for(int i =0; i<name.length(); i++) { for (int i = 0; i < name.length(); i++) {
char ch = name.charAt(i); char ch = name.charAt(i);
if(ch >='a' && ch<='z' || ch>='A' && ch<='Z') { if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z') {
continue ; continue;
} }
isValid = false; isValid = false;
} }
if(isValid) { if (isValid) {
System.out.println("\nThe Name "+ name + " is a Valid Name."); System.out.println("\nThe Name " + name + " is a Valid Name.");
} } else {
else { System.out.println("\nThe Name " + name + " is a Invalid Name.");
System.out.println("\nThe Name "+ name + " is a Invalid Name.");
} }
} }
......
package com.task3; package com.task3;
import java.util.Scanner; import java.util.Scanner;
public class CheckLeapYearOrNot { public class CheckLeapYearOrNot {
...@@ -9,10 +10,9 @@ public class CheckLeapYearOrNot { ...@@ -9,10 +10,9 @@ public class CheckLeapYearOrNot {
System.out.print("Enter Year... "); System.out.print("Enter Year... ");
int year = sc.nextInt(); int year = sc.nextInt();
if((year%400==0)|| (year%4==0 && year%100!=0)) { if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) {
System.out.println("\n"+ year + " is a Leap Year"); System.out.println("\n" + year + " is a Leap Year");
} } else {
else {
System.out.println("\n" + year + " is Not a leap year"); System.out.println("\n" + year + " is Not a leap year");
} }
......
package com.task4; package com.task4;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Calendar; import java.util.Calendar;
...@@ -10,30 +12,22 @@ public class DateFormates { ...@@ -10,30 +12,22 @@ public class DateFormates {
public static void main(String[] args) { public static void main(String[] args) {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
//System.out.println("Date: " + (cal.get(Calendar.MONTH)+1)+ "-" + (cal.get(Calendar.DATE)) + " Time : "+cal.get(Calendar.HOUR) + ":" + cal.get(Calendar.MINUTE)
// + ":" + cal.get(Calendar.SECOND) + "-" + (cal.get(Calendar.YEAR)) );
System.out.println("Current Date : " + cal.getTime()); System.out.println("Current Date : " + cal.getTime());
cal.add (Calendar.MONTH, 1); cal.add(Calendar.MONTH, 1);
System.out.println("After Add One Month in Current Date : " + cal.getTime()); System.out.println("After Add One Month in Current Date : " + cal.getTime());
System.out.println(" ----- First Task Done -----"); System.out.println(" ----- First Task Done -----");
Calendar cale = Calendar.getInstance(); Calendar cale = Calendar.getInstance();
System.out.println("\nCurrent Date : " + cale.getTime()); System.out.println("\nCurrent Date : " + cale.getTime());
cale.add(Calendar.DATE, -15); cale.add(Calendar.DATE, -15);
System.out.println("After Subsctract Fifteen Days From Current Date: " + (cale.get(Calendar.YEAR))+ " " + (cale.get(Calendar.MONTH)+1) + " "+cale.get(Calendar.DATE) + " " + cale.get(Calendar.HOUR) System.out.println("After Subsctract Fifteen Days From Current Date: " + (cale.get(Calendar.YEAR)) + " "
+ ":" + cale.get(Calendar.MINUTE) + " " + (cale.get(Calendar.SECOND)) ); + (cale.get(Calendar.MONTH) + 1) + " " + cale.get(Calendar.DATE) + " " + cale.get(Calendar.HOUR) + ":"
+ cale.get(Calendar.MINUTE) + " " + (cale.get(Calendar.SECOND)));
System.out.println(" ----- Second Task Done -----"); System.out.println(" ----- Second Task Done -----");
} }
} }
...@@ -5,8 +5,8 @@ public class FindSecondsAndMilliSeconds { ...@@ -5,8 +5,8 @@ public class FindSecondsAndMilliSeconds {
public static void main(String[] args) { public static void main(String[] args) {
long seconds = System.currentTimeMillis() / 1000l; long seconds = System.currentTimeMillis() / 1000l;
long milli = System.currentTimeMillis(); long milli = System.currentTimeMillis();
System.out.println("\nSeconds since 1970: "+seconds+"\n"); System.out.println("\nSeconds since 1970: " + seconds + "\n");
System.out.println("\nMillisecondsSeconds since 1970: "+milli+"\n"); System.out.println("\nMillisecondsSeconds since 1970: " + milli + "\n");
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment