Results 1 to 4 of 4
  1. #1
    felonee is offline Member
    Join Date
    Mar 2012
    Posts
    16
    Rep Power
    0

    Default Using Else/If for the first time - RuntimeException error

    Java Code:
    import java.io.*;
    import java.util.*;
    import java.text.*;
    
    
    public class NewHappyBirthday {
    
    public static void main(String[] args) throws IOException
    
    {
    String srgName, srgYear, srgMonth, srgDay;
    int iYearBorn, iMonthBorn, iDayBorn,  iCalendarNowDayOfYear; 	                        
    
    BufferedReader dataIn= new BufferedReader(new InputStreamReader(System.in));
                          
    System.out.println ("Hola. Please enter your name.");
    String Name = dataIn.readLine();
    
    System.out.println("Please enter the 4 digit year you were born.");
    srgYear = dataIn.readLine();
    iYearBorn = Integer.parseInt(srgYear);
    
    System.out.println("Please enter the numerical month you were born.");
    srgMonth = dataIn.readLine();
    iMonthBorn = Integer.parseInt(srgMonth);
    
    System.out.println("Please enter the date you were born.");
    srgDay = dataIn.readLine();
    iDayBorn = Integer.parseInt(srgDay);
    
    //create calendar called calendarNow and set it to the current time and date
    GregorianCalendar calendarNow = new GregorianCalendar();
    
    //long longNow = dateNow.getTime();
    int iCalendarBdayDayOfYear, iCalendarNowYear, iCalendarBdayYear;
    
    //create calendar called calendarBday and set it to the user's birthday 
    //(iMonthBorn-1 because Jan starts at 0)
    GregorianCalendar calendarBday = new GregorianCalendar(iYearBorn, iMonthBorn-1, iDayBorn);
    Date dateBday = calendarBday.getTime();
    
    //long longBday = dateBday.getTime();
    
    //create date format called df and output user's name and formatted birthday
    DateFormat df = DateFormat.getDateInstance();
    
    System.out.println("Hello " + Name + ". You were born on " + df.format(dateBday) + ". ");
    
    // variables for year and days of year 
    iCalendarNowDayOfYear = calendarNow.get(Calendar.DAY_OF_YEAR);
    iCalendarBdayDayOfYear = calendarBday.get(Calendar.DAY_OF_YEAR);
    iCalendarNowYear = calendarNow.get(Calendar.YEAR);
    iCalendarBdayYear = calendarBday.get(Calendar.YEAR);
    int iYearsOld, iDaysOld; int iNewBday, iDaysLeft;
    
    //  variables,  Formula for years and days old 
    
    iYearsOld = iCalendarNowYear - iCalendarBdayYear;
    iDaysOld = (iCalendarNowDayOfYear - iCalendarBdayDayOfYear);
    iNewBday = (iYearsOld + 1);
    iDaysLeft = ( 365 -  iDaysOld);
    
    //If your birthday was less than two weeks ago
    if (iDaysLeft > 351)
    
    System.out.printIn( "Hello, " + Name + ". How did your birthday party go? As of "
            + "today you are" + iYearsOld + " years and " + iDaysOld + 
            "days old." );  
     
    //Else if your birthday is in two weeks or less
    else if (iDaysLeft <= 14)
    
    System.out.printIn( "Hello, " + Name + ". I am excited to let you know that you "
            + "will be turning" + iNewBday + "in" + iDaysLeft + "days. "
            + "Do you have any birthday plans?" );
    
    //All others
    else
    
    System.out.printIn( "Hello " +Name + ". You are "+ iYearsOld + "years and " 
            + iDaysOld + " days old." );
        
        }
    
    }
    run:
    Hola. Please enter your name.
    Austin
    Please enter the 4 digit year you were born.
    2001
    Please enter the numerical month you were born.
    03
    Please enter the date you were born.
    27
    Hello Austin. You were born on Mar 27, 2001.
    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.io.PrintStream.printIn
    at pkgnew.happy.birthday.NewHappyBirthday.main(NewHap pyBirthday.java:88)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 11 seconds)
    Last edited by felonee; 03-25-2012 at 05:37 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Using Else/If for the first time - RuntimeException error

    println is not the same as printIn. In the correct version, the 6th letter is a lower-case "L" and in the incorrect version it's an upper-case "i".

  3. #3
    felonee is offline Member
    Join Date
    Mar 2012
    Posts
    16
    Rep Power
    0

    Default Re: Using Else/If for the first time - RuntimeException error

    Thank you so much. I couldn't tell in my book the difference between "I" and "l". Obviously I need new glasses or better light.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Using Else/If for the first time - RuntimeException error

    Quote Originally Posted by felonee View Post
    Thank you so much. I couldn't tell in my book the difference between "I" and "l". Obviously I need new glasses or better light.
    You're welcome and glad it helped.

Similar Threads

  1. Cant understand RuntimeException
    By Melssj5 in forum New To Java
    Replies: 2
    Last Post: 04-04-2011, 07:19 AM
  2. the compile time error is below
    By nicholil in forum New To Java
    Replies: 2
    Last Post: 11-07-2010, 02:52 AM
  3. Replies: 2
    Last Post: 10-30-2009, 12:55 PM
  4. Replies: 0
    Last Post: 07-06-2009, 03:38 PM
  5. java.lang.RuntimeException+ Axis
    By Peter in forum Advanced Java
    Replies: 1
    Last Post: 07-05-2007, 02:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •