// Earl Bergquist, Garfield High School
// Demonstrates methods that return with conditionals 
// and the cumulative sum pattern

import java.util.*;

public class CondReturnsSums {
	public static final int RETIREMENT_AGE = 65;

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		System.out.println("How old are you? ");
		int age = s.nextInt();
				int years = yearsUntil(age);
		System.out.println("You have " + years + " years until retirement.");
		System.out.println();
		
		// Days In Month Sample
		System.out.println("There are " + daysInMonth(2) + " days in February, month 2.");		
		System.out.println("There are " + daysInMonth(5) + " days in May, month 5.");
		System.out.println("There are " + daysInMonth(6) + " days in June, month 6.");
		System.out.println();
				
		//cumulative loop pattern
		int sumLimit = 10000;
		int total = 0;
		for(int i = 1; i <= sumLimit; i++) {
			total += i;	//same as total = total + i
		}
		System.out.println("The Sum Total is: " + total + " for Sum Limit: " + sumLimit);
	}
	
	// Calculate the years until a person of a given age retires
	public static int yearsUntil(int age) {
		if(age < RETIREMENT_AGE) {
			return RETIREMENT_AGE - age;
		} else  {
			return 0;
		}
	}
	
	// Given a month number (1 for Jan, 2 for Feb, etc), 
	// return the number of days it has (pretend there are no leap years!)
	public static int daysInMonth(int month) {
		if(month == 2) {
			return 28;
		} else if(month == 4 || month == 6 || month == 9 || month == 11) {
			return 30;
		} else {
			return 31;
		}
	}
	

}
