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

# Thread: Basic Java Program Help

1. ## 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:
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();

}

}

2. ## 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.

3. ## The Following User Says Thank You to elisha.java For This Useful Post:

Nuggets (January 17th, 2012)

4. ## Re: Basic Java Program Help

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.

5. ## 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?

6. ## The Following User Says Thank You to helloworld922 For This Useful Post:

Nuggets (January 17th, 2012)

7. ## Re: Basic Java Program Help

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?

8. ## 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.

9. ## 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.

10. ## The Following User Says Thank You to Mr.777 For This Useful Post:

Nuggets (January 17th, 2012)

11. ## Re: Basic Java Program Help

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.

12. ## 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.

13. ## The Following User Says Thank You to Mr.777 For This Useful Post:

copeg (January 17th, 2012)

14. ## Re: Basic Java Program Help

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.

15. ## Re: Basic Java Program Help

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...

16. ## 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:

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

17. ## Re: Basic Java Program Help

Alright, was confused because I didn't even see that persons response. Thanks copeg for the help!

18. ## 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.

19. ## 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...

20. ## Re: Basic Java Program Help

Given I have had to move several posts out of this thread to their own, I am locking this thread. Nuggets, apologies and if your question has yet to be answered please start another thread. Others, if you feel the need to discuss please start another thread.

21. ## The Following User Says Thank You to copeg For This Useful Post:

elisha.java (January 18th, 2012)