2010-10-24 02:41:48 UTC
I'm currently working on a project for a class and can't seem to figure out the cumulative sum for loops...for the project we need to calculate the absolute day of the current date the birthday of the user. I'm just not exactly sure how to turn a date (like 3/27) into it's absolute day by using the for loop.... This is what I have so far:
public static int totalDays(int month, int day) {
int total = 0;
for (int i = 1; i <= month; i++) {
total += 31;
total += 28;
total += 31;
...
total += day;
System.out.print(month + "/" + day + " is day #" + total + "of 365!");
return total;
I know it's probably really wrong, but as I said, I really don't get it.... Could someone set me straight on how to use this type of for loop? Thank you!