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

update

parent fd2d9a7d
package com.task1;
import java.util.Scanner;
public class StringValidity {
public static void main(String[] args) {
......@@ -7,22 +9,21 @@ public class StringValidity {
Scanner sc = new Scanner(System.in);
System.out.print("Enter A Name .. ");
String name = sc.nextLine();
boolean isValid=true;
for(int i =0; i<name.length(); i++) {
boolean isValid = true;
for (int i = 0; i < name.length(); i++) {
char ch = name.charAt(i);
if(ch >='a' && ch<='z' || ch>='A' && ch<='Z') {
continue ;
if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z') {
continue;
}
isValid = false;
}
if(isValid) {
System.out.println("\nThe Name "+ name + " is a Valid Name.");
}
else {
System.out.println("\nThe Name "+ name + " is a Invalid Name.");
if (isValid) {
System.out.println("\nThe Name " + name + " is a Valid Name.");
} else {
System.out.println("\nThe Name " + name + " is a Invalid Name.");
}
}
......
package com.task3;
import java.util.Scanner;
public class CheckLeapYearOrNot {
......@@ -9,10 +10,9 @@ public class CheckLeapYearOrNot {
System.out.print("Enter Year... ");
int year = sc.nextInt();
if((year%400==0)|| (year%4==0 && year%100!=0)) {
System.out.println("\n"+ year + " is a Leap Year");
}
else {
if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) {
System.out.println("\n" + year + " is a Leap Year");
} else {
System.out.println("\n" + year + " is Not a leap year");
}
......
package com.task4;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar;
......@@ -10,30 +12,22 @@ public class DateFormates {
public static void main(String[] args) {
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());
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(" ----- First Task Done -----");
Calendar cale = Calendar.getInstance();
System.out.println("\nCurrent Date : " + cale.getTime());
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)
+ ":" + cale.get(Calendar.MINUTE) + " " + (cale.get(Calendar.SECOND)) );
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) + ":"
+ cale.get(Calendar.MINUTE) + " " + (cale.get(Calendar.SECOND)));
System.out.println(" ----- Second Task Done -----");
}
}
......@@ -5,8 +5,8 @@ public class FindSecondsAndMilliSeconds {
public static void main(String[] args) {
long seconds = System.currentTimeMillis() / 1000l;
long milli = System.currentTimeMillis();
System.out.println("\nSeconds since 1970: "+seconds+"\n");
System.out.println("\nMillisecondsSeconds since 1970: "+milli+"\n");
System.out.println("\nSeconds since 1970: " + seconds + "\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