/* * Lab 2, Part 1 Practice writing Methods * * name: CS 112 Course Staff */ import java.util.*; public class Insults { /* * This method is the entry point of our program. * * This method should be used to call the individual methods * that have been written as specified in lab. * * This method prompts for an age and displays * an insult accordingly */ public static void main(String[] args) { Scanner scan = new Scanner( System.in ); int age; System.out.print( "How old are you? " ); age = scan.nextInt(); System.out.println( insult( age ) ); } /* * This method forms a string based on the value * of the age argument. */ public static String insult( int age ) { String insult; if ( age <= 0 ) insult = "You are an idiot who does not pay attention to directions."; else if ( age < 20 ) insult = "You're such a dweeb!"; else if ( age < 30 ) insult = (30 - age) + " more years until 30!"; else if ( age < 50 ) { insult = "Being an adult is rough."; } else { insult = "Yikes."; } return( insult ); } }