Epic Systems Interview Question
Software Engineer / Developers1) function which lists all possible dates?? in which language?
2) well, for second question i believe, you need to use ASCII, like read the alphabet, convert it to ascii using functions like itoa or atoi and append that shud be the way more or less to do it...i am guessing...havent yet strtd preparing though !! :(
3) well, so suppose u know that password is 8 digits... i guess, you just have to write a function that iterates and tries all combinations for 8 digits...more like brute forcing the password...der is no way to guess it...
Thats just my highly abstract shot at the questions
public void returnMe(int year) {
Boolean leapYear = (year % 4 == 0 && year % 100 != 0)?true:false;
for (int month = 1; month <= 12; month++){
for (int date = 1; date <= 31; date++){
if (date > 28 && month == 2 && !leapYear ||
date > 29 && month == 2 && leapYear)
break;
if (date > 30 && (month == 4 || month == 6 || month == 9 || month == 11))
break;
System.out.println(year + "-" + month + "-" + date);
}
}
}
public static void printDates(int year)
{
boolean leapY = false;
if(year%400==0||year%4==0&&year%100!=0) leapY =true;
int mon = 0;
int day = 0;
for(mon =1;mon<=12;mon++)
{
for(day=1;day<=28;day++)
System.out.println(mon+"/"+day);
if(mon==2&&leapY)
System.out.println(mon+"/"+29);
if(mon!=2)
for(day=29;day<=30;day++)
System.out.println(mon+"/"+day);
if(mon%2==1&&mon<8||mon>7&&mon%2==0)
System.out.println(mon+"/"+31);
}
}
public static void printDates(int year)
{
boolean leapY = false;
if(year%400==0||year%4==0&&year%100!=0) leapY =true;
int mon = 0;
int day = 0;
for(mon =1;mon<=12;mon++)
{
for(day=1;day<=28;day++)
System.out.println(mon+"/"+day);
if(mon==2&&leapY)
System.out.println(mon+"/"+29);
if(mon!=2)
for(day=29;day<=30;day++)
System.out.println(mon+"/"+day);
if(mon%2==1&&mon<8||mon>7&&mon%2==0)
System.out.println(mon+"/"+31);
}
}
public class LeapYear {
static Boolean leap = false;
public static void printAllDays(int year){
if(year%400==0 || (year%4==0 && year%100!=0)){
leap = true;
}
System.out.println("For the year" +year);
for(int m=1; m<13; m++){
for(int day=1; day<32; day++){
if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12){
System.out.println(+m +"-" +day +"-" +year);
}
else{
if(m!=2 && day!=31){
System.out.println(+m +"-" +day +"-" +year);
}
if(m==2 && leap==true && day<30){
System.out.println(+m +"-" +day +"-" +year);
}
if(m==2 && leap==false && day<29){
System.out.println(+m +"-" +day +"-" +year);
}
}
}
}
}
public static void main(String args[]){
printAllDays(1000);
}
}
#include<stdio.h>
void printAllDates(int year) {
int days[2][13] = { {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
};
int i,j;
int leap = (year%4==0)&&(year%400==0&&year%100!=0);
char *months[13] = {"", "JAN", "FEB", "MAR", "APR", "MAY", "JUNE", "JULY", "AUG", "SEP", "OCT", "NOV", "DEC"};
for(i=1;i<=12;i++)
for(j=1;j<=days[leap][i];j++)
printf("%2d %s %d\n", j, months[i], year);
}
int main() {
printAllDates(2000);
}
public static void printDates (int year) {
boolean isLeapYear = (year%400 == 0 || (year%4 == 0 && year%100 != 0))? true:false;
int daysInFeb = (isLeapYear)? 29:28;
int[] daysOfMonth = {31, daysInFeb, 31,30,31,30,31,31,30,31,30,31};
for (int month=1; month<=12; month++) {
for (int day=1; day<=daysOfMonth[month-1]; day++) {
System.out.println(month+"-"+day+"-"+year);
}
}
}
void printDate(){
- Cooked March 30, 2009int yearInput = 2100;
int months = 12;
int days = 31;
int i ,j;
for ( i=1;i<=12;i++){
if( ( i <= 7 && i % 2 !=0) || ( i >=8 && i %2 ==0)){
//its 31 dates
days=31;
}
else if( (i!=2) && (( i <=7 && i%2 == 0) || (i>=9 && i%2!= 0))){
// its 30 days
days = 30;
}
else{
//its feb
days = 28;
if( ((yearInput % 4 == 0) && (yearInput % 100 !=0)) || (yearInput%400 == 0) )
days = 29;
}
for(j=1;j<=days;j++){
printf ("\nDay:%2d, Month:%2d , Year:%4d",j,i,yearInput);
}
}
}