# Basic Java Program Help

• January 16th, 2012, 06:01 PM
Nuggets
Basic Java Program Help
Need help with a java program assignment for school. Here is the problem:

We are all looking forward to retiring someday. Assuming we will retire on our 65th birthday, write a Java program that prompts the user for his/her birthday month, day, and year and then prints out the date the user will retire.

I am having trouble calculating when the user will turn 65. Here is what I have so far:
Code :

```package com.mime.project1;   import java.util.Scanner;   public class Assign2 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in);   int month, day, year;   System.out.print("Enter the month you were born: "); month = stdIn.nextInt(); System.out.print("Enter the day you were born: "); day = stdIn.nextInt(); System.out.print("Enter the year you were born: "); year = stdIn.nextInt();     }   }```
• January 16th, 2012, 08:21 PM
elisha.java
Re: Basic Java Program Help
You need to think of the retirement year with reference to the year entered by the user and the value 65. Note: This is not where you get people to do your homework. Now, what is the relationship between the age of the user as calculated by from the information provided, and the value 65? That is how you will know how many years remain for active work before retirement.
• January 16th, 2012, 09:03 PM
Nuggets
Re: Basic Java Program Help
Quote:

Originally Posted by elisha.java
You need to think of the retirement year with reference to the year entered by the user and the value 65. Note: This is not where you get people to do your homework. Now, what is the relationship between the age of the user as calculated by from the information provided, and the value 65? That is how you will know how many years remain for active work before retirement.

I'm still having a hard time understanding how to calculate the years.
• January 16th, 2012, 09:40 PM
helloworld922
Re: Basic Java Program Help
Hint:

Say you were born the year 0. What year would you be 65?
Now say your friend was born year 1. What year would they be 65?

Now how do you generalize this to someone born year y?
• January 16th, 2012, 09:51 PM
Nuggets
Re: Basic Java Program Help
Quote:

Originally Posted by helloworld922
Hint:

Say you were born the year 0. What year would you be 65?
Now say your friend was born year 1. What year would they be 65?

Now how do you generalize this to someone born year y?

Okay, so I would have to set the value of the inputted year to equal 0 right? Then I would need a for loop to count the years until it reaches 65?
for (year=0; year<65; year++)
Am I getting closer or no?
• January 16th, 2012, 10:22 PM
Nuggets
Re: Basic Java Program Help
One more hint guys, please. Is it a for, if or while loop? All the for loop did was count up to 65 for the year. I need it to output the exact year the person will turn 65, not the number 65.
• January 17th, 2012, 12:14 AM
Mr.777
Re: Basic Java Program Help
@Nuggets: Get a copy and pencil and write down how will you solve it if the same problem is given to you to solve manually?
Write down the steps clearly as you followed manually to solve the problem.
Implement those steps in your program.

Note: You don't need any loop for this program.
• January 17th, 2012, 12:29 AM
Nuggets
Re: Basic Java Program Help
Quote:

Originally Posted by Mr.777
@Nuggets: Get a copy and pencil and write down how will you solve it if the same problem is given to you to solve manually?
Write down the steps clearly as you followed manually to solve the problem.
Implement those steps in your program.

Note: You don't need any loop for this program.

That helped a lot, thanks! So I just need to add 65 to the year inputted (year += 65). Wow, made this problem a lot more complicated than it was.
• January 17th, 2012, 06:19 AM
Mr.777
Re: Basic Java Program Help
@neeraj0708: If you would just spend few minutes to read Forums Rules, you will come to know that spoon feeding is not allowed.

Request to Admin or Moderators: Kindly ban such users who try to spoon feed as they don't even bother to read forums rules or create a test to get successful registration on the forums and test must contain all the forums rules.
• January 17th, 2012, 10:04 AM
copeg
Re: Basic Java Program Help
Quote:

Originally Posted by Mr.777
@neeraj0708: If you would just spend few minutes to read Forums Rules, you will come to know that spoon feeding is not allowed.

Request to Admin or Moderators: Kindly ban such users who try to spoon feed as they don't even bother to read forums rules or create a test to get successful registration on the forums and test must contain all the forums rules.

The user has been warned accordingly and deleted their thread on their own.
• January 17th, 2012, 05:30 PM
Nuggets
Re: Basic Java Program Help
Quote:

Originally Posted by Mr.777
@neeraj0708: If you would just spend few minutes to read Forums Rules, you will come to know that spoon feeding is not allowed.

Request to Admin or Moderators: Kindly ban such users who try to spoon feed as they don't even bother to read forums rules or create a test to get successful registration on the forums and test must contain all the forums rules.

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.

How am I supposed to gain knowledge through this forum? "We invite beginner Java programmers right through to Java professionals to post here and share your knowledge." I'm sorry I don't know as much as you about programming Java, as I only started 2 weeks ago. Am I not allowed to ask for help on certain things? Why is information so privy? What's so bad about asking for some help? Maybe I shouldn't have said it was for school. Anyways, I'm disappointed in this forum. I guess when I get to your level of expertise in Java, I know I shouldn't try and help a beginner out, or point him in a kind direction...
• January 17th, 2012, 06:11 PM
copeg
Re: Basic Java Program Help
Dear Nuggets, you may have misunderstood the above ruckus as being directed towards you - it was not. Rather it was directed towards a member who was doing what is called 'spoon-feeding' (and whose post was subsequently deleted), which is against forum rules:

Quote:

Providing homework solutions in full or in part is frowned upon, and contributions that are considered as such will be subject to moderation (editing and/or deletion)

The following article should give you an idea as to why this rule exists

The Problem with Spoon-feeding
• January 17th, 2012, 06:23 PM
Nuggets
Re: Basic Java Program Help
Alright, was confused because I didn't even see that persons response. Thanks copeg for the help!
• January 17th, 2012, 09:29 PM
elisha.java
Re: Basic Java Program Help
Should we sometimes be worried of the side-effects of our tough language towards new programmers before doing anything or just go ahead scaring them away? I will never tolerate spoon-feeding but I wonder if telling them how wrong they are will help them. It would be easier if we all started and went pro the same day or week! I am not creating an affinity for conflict but I believe that we should learn to tame talents that will replace our own when our times are up! Thank you.
• January 17th, 2012, 09:48 PM
copeg
Re: Basic Java Program Help
This thread has been slightly pushed off course...lets please stay on topic. Its not to deny anyone their piece of mind, but in the effort to keep the forums organized please start a new thread for discussion not related to the original topic.

Nuggets, I am not sure if your problem that started this thread has been solved or not. If so, please mark the thread as solved, otherwise please update this thread with the appropriate information/questions/etc...
• January 18th, 2012, 12:47 AM
copeg
Re: Basic Java Program Help