Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: please help!

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default please help!

    This is due in a few hours....this is the first java program I have been asked to write and I have no idea how to do it and I left my textbook in my friend's car.

    I have to write a program that asks a user for their birth month, birth date, and birth year, and then tell them what day they will turn 100. This is what i have so far.
    import java.util.Scanner;
     
    public class PrintBirthday
    {
      public static void main(String[] args)
      {
        Scanner stdIn = new Scanner(System.in);
        String month; // birthday month
        double day; // birth day
        double year; //birth year
        double oldyear = 0; //year turning 100
        System.out.print(
          "Enter the month you were born: ");
        month = stdIn.next();
        System.out.print(
    		"Enter the day you were born: ");
    	day = stdIn.nextDouble();
    	System.out.print(
    		"Enter the year you were born: ");
    	year = stdIn.nextDouble();
    	oldyear += year+100;
        System.out.println("You will be 100 on " +
          month() + day() + oldyear(0));
      } // end main
    } // end class PrintBirthday

  2. #2
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: please help!

    That looks about right - apart from the obvious syntax errors. Fix those and tell us what the output is.

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Location
    IN
    Posts
    14
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: please help!

    This is your final code.

    (spoon-feeding code removed by KevinWorkman)
    Last edited by KevinWorkman; September 20th, 2011 at 07:42 AM.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: please help!

    Quote Originally Posted by treacyjane View Post
    This is your final code.
    Spoon-feeding is NOT helpful. Sean4u had the right approach. Please read this before you post again: http://www.javaprogrammingforums.com...n-feeding.html
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!