Here’s a little Java program that calculates the Acceptable Dating Age Range, based on this comics http://www.xkcd.com/314/ which basically says that as you get olderĀ the dateable age range gets wider based on this formula DateableRange = ( Age/2 ) + 7
Java Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | package testproject; /** * * @author jorge */ import java.util.*; public class DatingRange { public static void main(String[] args) { // TODO code application logic here Scanner Age = new Scanner (System.in); //asking the user for age System.out.println("How old are you?"); int UserAge = Age.nextInt(); //calculating acceptable range int AcceptableRange = (UserAge/2)+ 7; //calculating Difference int Diff = UserAge - AcceptableRange; //calculating the oldest you can date int oldest = UserAge + Diff; //output information to user System.out.println("You are "+UserAge+" years old!"); System.out.println("The youngest you can date is "+AcceptableRange+" years old!"); System.out.println("The oldest you can date is "+oldest+" years old!"); } } |