Skip to content

Instantly share code, notes, and snippets.

@lukihardt
Created March 20, 2019 14:55
Show Gist options
  • Select an option

  • Save lukihardt/68cf28b2cafea69f2c364cb31ef04db7 to your computer and use it in GitHub Desktop.

Select an option

Save lukihardt/68cf28b2cafea69f2c364cb31ef04db7 to your computer and use it in GitHub Desktop.
counts today is odd week or even
import java.util.Scanner;
/**
* counts today is odd week or even
*/
public class CountOddEven {
public static void main(String[] args) {
System.out.println("Enter month:(1-12)");
int mon = new Scanner(System.in).nextInt();
System.out.println("Enter day:(1-31/28/29/30)");
int day = new Scanner(System.in).nextInt();
int totalDays = 0;
switch (mon){
case 3: totalDays += 10;break;
case 4: totalDays += 10 + 31;break;
case 5: totalDays += 10 + 31 + 30;break;
case 6: totalDays += 10 + 31 + 30 + 31;break;
case 7: totalDays += 10 + 31 + 30 + 31 + 30;break;
case 8: totalDays += 10 + 31 + 30 + 31 + 30 + 31;break;
case 9: totalDays += 10 + 31 + 30 + 31 + 30 + 31 + 31;break;
case 10: totalDays += 10 + 31 + 30 + 31 + 30 + 31 + 31 + 30;break;
case 11: totalDays += 10 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31;break;
case 12: totalDays += 10 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30;break;
default:
System.out.println("error"); break;
}
totalDays += day;
System.out.println("hah,"+totalDays+" days passed");
int weeks = totalDays / 7 + 1;
if (weeks % 2 == 0){
System.out.println("Even week");
}
else {
System.out.println("Odd week");
}
}
}
@lukihardt
Copy link
Author

(count today is odd week or even)newcomer's little code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment