Java Program Help

Status
Not open for further replies.
To the mods: I'm very very sorry if this isn't allowed, please lock this if it isn't, this is the only place I could find this being okay to put for help...sorry if it's not ok.

Ok all you Computer Science experts! (I hope lol) I need some help doing this project for computer science, it's extra credit and the more complex it is the mroe credit I can get. I screwed up on a test and got some stuff backwards and lets just say my average isn't where I'd like it to be! lol. Anyway we're not THAT far into the programming so I did something I knew I could handle on my own, but after I was done I wasn't satisfied with it because of how simple it is, so can anyone help me make it a more complicated program to help get more points? Here it is:

Code:
// job profile  profile.java
    import java.util.*;
    class profile
{
    public static void main (String[] args) 
  {
        
	System.out.println("The purpose of the program is to make a summary of a person by input of data.");
        System.out.println();

	Scanner bob = new Scanner (System.in);


	// Users Name
	   System.out.println("What is your name?");
	   String name = bob.nextLine();
   	   System.out.println();

	// Users Birthday
	   System.out.println("What year were you born in?");
	   String bday = bob.nextLine();
	   System.out.println();

	// Users Birthplace
	   System.out.println("What city were your born in?");
	   String birthplace = bob.nextLine();
	   System.out.println();

	// Users School
	   System.out.println("What school did you graduate from?");
	   String highschool = bob.nextLine();
	   System.out.println();

	// Users College
	   System.out.println("What College did you attend?");
	   String college = bob.nextLine();
	   System.out.println();

	// Users Degree in college
	   System.out.println("What degree in college - Bachelor, Masters, or Docterate?");
	   String degree = bob.nextLine();
	   System.out.println();

	// Users Major in college
	   System.out.println("What did you major in college?");
	   String major = bob.nextLine();
	   System.out.println();

	// Todays date
	   System.out.println("What is todays date? MM/DD/YY");
	   String date = bob.nextLine();
	   System.out.println();

	// Users Location
	   System.out.println("Where do you live?");
	   String location = bob.nextLine();
	   System.out.println();

	// Users hobbies
	   System.out.println("What is a hobby you enjoy?");
	   String hobby = bob.nextLine();
	   System.out.println();

	// Users Birthday
	   System.out.println("What year were you born in?");
	   int bdayyr = bob.nextInt();
	   System.out.println();

	// Current Year
	   int date2 = 2008;

	// users age
	   int age = date2 - bdayyr;

	// Summary in paragraph form
	   System.out.println("Hello, nice to meet you " + name + ".");
	   System.out.println("You were born in the year " + bday + " and born in " + birthplace + ", that's a nice town.");
	   System.out.println("So anyway, back to you, you graduated at " + highschool + " then went to " + college + " and got your " + degree + " in " + major + ".");
	   System.out.println("And now you are currently living in " + location + " and you enjoy " + hobby + ".");
	   System.out.println("Do you know what today is?");
	   System.out.println("Well since you're getting old at the age of " + age + ", I'll just go ahead and tell you it's " + date + ".");
	   System.out.println("Hehe I couldn't resist the old joke, so sorry about that!");
	   System.out.println("Anyway it was nice meeting you! See ya round.");
  }
}

Ok so just to help point out what it does as it is NOW:

The program asks the user basic questions, the user then inputs the data it wants (IE: "What year were you born in?" 1991) then stores the input into a variable. Later, it outputs all the data taken in into a paragraph structure and basicly gives a small summery of the person running the program.

Even without making it better, one "flaw" is that the age will only be correct if the user's birthday has already happened in the year, and I don't know how to fix that.

Thanks,
-Matt
 
You asked what year they were born in twice.

If you want to get the age correct, you're going to need more data than just the year. Obviously, you will need the day and the month. You can surely do the math from there.
 
Well I know that I need the day and the month but I don't know how to turn that into a ratio or whatever to still make the Date - Birthday work. Also I put in year twice because for SOME reason, at the top when I put it as an integer it made it skip the next Q (like show it but not let you input) which messed up the program. The alternative I did was make them enter it twice =/
 
Have you used if or else statements in java yet? That would help along the process.
i.e. - if his the day/month he's entered for his birthday is less than the current day/month subtract the inputted year from the current year. elsedo the same calculation and subtract one from the difference.
You can assign numerical values to each of the months according to the days of the year that have passed up until the first day of that month, and then add the day number the user's inputted to that.

ex: January = 0; user inputs January 3, 1990 current date is november 4, 2008.

2008 - 1990 = 18; november 4 is the 308th day, january 3 is the 3rd. since 308 is obviously greater than 3, output 18. If his birthday was nov 5, per se, it would be greater than the current date, and he'd actually be seventeen.

There's probably a more efficient method of doing this, but I'm fairly sure you want to keep it basic.
if you haven't used if/else though, this is moot.

If you don't mind me asking, what grade level is this project for?

EDIT- or yeah just use pre-programmed object oriented like justin said
 

Ok I'll look into it and try to figure it out.

Have you used if or else statements in java yet? That would help along the process.
i.e. - if his the day/month he's entered for his birthday is less than the current day/month subtract the inputted year from the current year. elsedo the same calculation and subtract one from the difference.
You can assign numerical values to each of the months according to the days of the year that have passed up until the first day of that month, and then add the day number the user's inputted to that.

ex: January = 0; user inputs January 3, 1990 current date is november 4, 2008.

2008 - 1990 = 18; november 4 is the 308th day, january 3 is the 3rd. since 308 is obviously greater than 3, output 18. If his birthday was nov 5, per se, it would be greater than the current date, and he'd actually be seventeen.

There's probably a more efficient method of doing this, but I'm fairly sure you want to keep it basic.
if you haven't used if/else though, this is moot.

If you don't mind me asking, what grade level is this project for?

EDIT- or yeah just use pre-programmed object oriented like justin said

I'm in 11th grade, but this is the first time I've ever had any kind of a programming class and I only know as much as I've been shown. Yes we've done if/else a few times...I'll try to make one like you said (we only did it like twice so I'm not as familiar with it, but I can figure it out).

Any other ideas?

-Matt
 
You could make it better by making it check whether the date you enter is in the correct format MM/DD/YY, though I don't know if you've done string handling methods yet.
 
Good for you! It's great to get into programming when you're young.

Another thing you could do... just use bday as an int (so that you only ask for the bday once) and then convert it to a string using the .tostring() method.
 
man i was gonna waltz into this topic as a fountain of knowledge but yall got here first
 
Status
Not open for further replies.
Back
Top