Commit 79e03410 authored by a-j.towse's avatar a-j.towse

MonthBetween

parent 1d45eca2
import java.time.Year;
//Excercises for week 2
public class App {
......@@ -45,43 +47,21 @@ public class App {
}
}
public static void main(String[] args) throws Exception {
countDays();
circumference(10);
inigoSpeech(6);
isItALeapYear(2016);
int month = 0;
for(month = 1; month < 14; month++){
switch(month){
case 1 : System.out.println("January");
break;
case 2 : System.out.println("February");
break;
case 3 : System.out.println("March");
break;
case 4 : System.out.println("April");
break;
case 5 : System.out.println("May");
break;
case 6 : System.out.println("June");
break;
case 7 : System.out.println("July");
break;
case 8 : System.out.println("August");
break;
case 9 : System.out.println("September");
break;
case 10 : System.out.println("October");
break;
case 11 : System.out.println("Novemeber");
break;
case 12 : System.out.println("December");
break;
default : System.out.println("Not a valid month");
break;
/*public static String monthCount(int monthNum){
switch(monthNum){
case 1 : return("January");
case 2 : return("February");
case 3 : return("March");
case 4 : return("April");
case 5 : return("May");
case 6 : return("June");
case 7 : return("July");
case 8 : return("August");
case 9 : return("September");
case 10 : return("October");
case 11 : return("Novemeber");
case 12 : return("December");
default : return("Not a valid month");
}
}
while(month < 14){
......@@ -145,6 +125,58 @@ public class App {
break;
}
}while(month < 14);
}*/
public static int daysInMonth(int monthNum, int currentYear){
if(isItALeapYear(currentYear) == true){
int febDays = 29;
}
else{
int febDays = 28;
}
switch(monthNum){
case 1 : return(31);
case 2 : return(febDays);
case 3 : return(31);
case 4 : return(30);
case 5 : return(31);
case 6 : return(30);
case 7 : return(31);
case 8 : return(31);
case 9 : return(30);
case 10 : return(31);
case 11 : return(30);
case 12 : return(31);
default : return(1);
}
}
public static int daysMonthLeft(int startDay, int startMonth, int currentYear){
int daysLeft = (daysInMonth(startMonth,currentYear)-startDay);
return daysLeft;
}
public static int daysBetween(int startDay, int startMonth, int startYear, int endDay, int endMonth, int endYear){
System.out.println(monthCount(12));
int days = 0;
days += daysMonthLeft(startDay, startMonth, currentYear)
return days;
}
public static void main(String[] args) throws Exception {
/*countDays();
circumference(10);
inigoSpeech(6);
isItALeapYear(2016);
*/
......
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