Hi ALL,
Here I wrote a program for simple Finding Day program in java.
/**
*
* @author Balamurgan
M
*/
import java.util.Scanner;
import java.util.Date;
public class day_find {
public static void
main(String arg[]){
int rday;
int day;
System.out.println("enter remaining days to meet your friend
\t");
Scanner in=new
Scanner(System.in);
rday=in.nextInt();
Date d=new
Date();
//
System.out.println("date "+d.getDay());
int today =
d.getDay();
//
System.out.println("taday "+today);
day=(rday+today)%7;
switch(day){
case 0:
System.out.println("Sunday");
break;
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wendesday");
break;
case 4:
System.out.println("Thusday");
break;
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
default:
System.out.println("Wrong input");
}
}
}
No comments:
Post a Comment