Trying to write a code for my intro to java course but unable to reset int value.
For my intro course, I have to write a program that determines a due date based on the type of book the user is checking out. I am not allowed to use any date formats, just simply inputting month day and year as integers.
The main part of this program is that new books have a 14 day check out and non -new books have a 21 day check out limit. I have figured out how to add the specified number of days based on the type of book, but given that days, months and year are defined as integers, how would I reset the days if the inputted date of the check out exceeds the number of day within that particular month?
I know how to format it to display it continuing over to the next month. But say the user inputs the check out day is the 15 of February, how would my program know how to restart counting on the next month but also know when it's reaching its limit of either 14 or 21 days?
String releaseType;
int coMonth, coYear;
int coDays = 0;
// determing how many days added to due date
if (releaseType == "NEW"){
coDays += 14;
}else{
coDays += 21;
}
if (coDays > 30){
coMonth +=1;
}
if (coMonth >12){
coYear +=1;
}
System.out.println("You due date is " + coMonth + "/" + coDays + "/" + coYear);
Input data: NEW, 2 (month) 15 (day) 2019 (year) output: You due date is 3/36/2019