How To Add Numbers To Dates



Trying to figure out how to add dates to a non-specified int using an if statement.

Trying to write a program that would be used for a library system. In which the user must input the type of item being checked out. (Either classified as NEW or OLD). The user must also the checkout date. If the item is classified as NEW then the due date is 14 days after the checkout date. Otherwise, if it's not a new item, the use has 21 days. How would I write an if statement that allows me to add either 21 or 14 to the date of the day the user inputs? I tried using a for loop but given the exact day isn't define and the user may enter whatever day they please, I'm having difficulty getting my intended output. This is for my intro Java course, so there may be some elements that I haven't learned yet. Below is some code that I would have thought would work but given that there is no pre-defined value for coDay, I'm having trouble figuring out how it would successfully add 14 days to the inputted day.

String releaseType;
int coDay;

for (int i = 0; i <= 14; i++){
if(releaseType == "NEW"){


If the user inputs "2" for coDay and "NEW" for releaseType, I'm expecting the coDay to be 16.

Continue reading...