// Helene Martin, Garfield High School
// Demonstrates methods that return with conditionals 
// and the cumulative sum pattern

import java.util.*;

public class CondReturns {
	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(daysInMonth(5));
		
		//cumulative loop pattern
		int total = 0;
		for(int i = 1; i <= 10000; i++) {
			total += i;	//same as total = total + i
		}
		System.out.println("the total is: " + total);
	}
	
	// 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;
		}
	}
	
	// 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;
		}
	}
}
