Heya guys. I'm having a real problem with one of the examples on my java homework and was hoping one of you guys/gals could help. I need to write a program that allows the input of five numbers. Then the final output line(s) need to say which is the highest and lowest number. I asked the professor for help but it seem that he is a math teacher who was just the most qualified even though he doesn't seem to know java... I'm really stuck here, if anyone could help me I would really appreciate it a lot! Thanks a whole bunch!

Jenna

Use a scanner to get the input. Use a variable for "highest" and one for "lowest". Compare the input to those and alter as needed.

I'm a website major and don't know a bit of java, they made it a requirement in my program without any programming prerequisites. Class is in 45 minutes! I appreciate the general help you gave me but I am java illiterate... Thanks.

What is a "website major"? ... Never heard of that one.

Anyway, I'll be more specific since I'm feeling nice today, even though Ezzaral gave you more than enough to figure it out.

1. Create two variables - if the user has to be able to enter integers, then use 'int' variables, if they can enter decimal numbers, then use 'double' variables. Create one variable called highest and one variable called lowest.

2. You need to prompt the user to enter values. You can use System.out.println() to do this. Look it up for examples.

3. You need to use Scanner to read in the value. Look up 'Scanner' on google to learn how to read in (Integers/ Doubles) depending on which of the two you are using (see 1).

4. You need two if statements: one to compare the int/double you just read in to 'lowest' and one to compare it to 'highest'. If it is lower than lowest, store it in lowest. If it is higher than highest, store it in highest.

5. Use System.out.println() to print out the lowest and highest.

I'm pretty confident nobody can spell it out for you more than that, so take it or leave it, but if you can't complete your assignment, it is nobody's fault except your own.

Wow, that might have been the single most condescending post in the history of forums. First about my major which is "Website Design and Administration" and I'm only a year and a half in. (html, ccs) And then talking down again at the end. It could have taken you half the time to write the code as it would have to written me your angry ordered list. This is probably the only place in the world you are king so you flaunt it, Mr. Condescension. No reason to be nasty. Thanks.

Jenna

commented: Wow, are you this rude to everyone that takes time to write out detailed instructions for your homework assignments? -2

He wasn't being rude, he was just telling it like it is. You should grateful that he told exactly how to do the problem, not mad that he made a comment about your major. Follow his "angry ordered list" and you should be able to solve your problem. Also, next time you have an assignment, don't wait until the day its due to start asking for help.

commented: Thank God for computer majors. :) +4

Wow, that might have been the single most condescending post in the history of forums. First about my major which is "Website Design and Administration" and I'm only a year and a half in. (html, ccs) And then talking down again at the end. It could have taken you half the time to write the code as it would have to written me your angry ordered list. This is probably the only place in the world you are king so you flaunt it, Mr. Condescension. No reason to be nasty. Thanks.

Jenna

Actually, I'm far from a "king" here, I'm not even a moderator, and I hardly talk to anyone else on the site. Nice try at summing up the overall picture on a site you just registered on, though. Too bad you fail. :( (Get it, you fail at summarizing the situation as well as failing on your assignment)

Oh, and I was just light-heartedly joking about the major thing. I'm a computer science major - I wouldn't tell anyone that I am a "computer major". I was poking fun, not calling you an idiot. Had you noticed how I then spent five minutes explaining to you, step by step, exactly how to do your assignment and exactly what you needed to research to do the job, it would have been obvious to you that I was helping you, not making fun of you.

Have a nice day,

:)

(Get it, you fail at summarizing the situation as well as failing on your assignment)
:)

Your so clever, hows that working out for ya? Bet it doesn't get ya laid.

Shouldnt you be in class now? Cutting class isnt gonna help your already self proclaimed poor java skills.

Shouldnt you be in class now? Cutting class isnt gonna help your already self proclaimed poor java skills.

I'm in class right now. Wow you guys are coming out of the woodwork in defense of the king eh? There are computers in a java class - nutty concept.

Maybe you should try paying attention and try to learn the material. Instead of arguing over pointless matters, listen to your teacher and try to learn something. Believe it or not, there are people in the world who know things that you do not.
By the way, maybe you should practice what you preach and try not being mean to the people who are trying to help you. And I'm not coming out of the woodwork I'm on this site almost everyday. I like helping people who aren't arrogant jerks. So maybe you should just sign off now...

Your so clever, hows that working out for ya? Bet it doesn't get ya laid.

Put "Website Major" in your resume, and I bet you never get a job. But seriously, the lack of social skills and self motivation is probably a good cue for where your future is going.

I'm in class right now. Wow you guys are coming out of the woodwork in defense of the king eh? There are computers in a java class - nutty concept.

Why do you even go to class? You don't do the homework and then you're on the computer the entire time.

P.S. There is a picture of myself and my girlfriend in my profile, once again, good try with the personal attacks though. 0/2 on personal attacks, 0/1 on homework assignments. ;)

Also, I'm done here, somebody close this before it gets any more out of hand.

commented: Hot girlfriend. Good going man :) +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.