![]() |
![]() |
![]() |
|
Enthusiast ![]() Joined Feb 3, '04 From North Carolina Currently Offline Reputation: 0 (0%) ![]() |
I am new to java and wanted to figure out an example we did in class but i cant do it. i was wondering if anyone could point me in the right direction. it's a really simple program...i just cant figure out how to do it lol cause im new.
i want the program to ask the user to enter 2 integers. and then print out all the integers between the 2 numbers. thats all. i know i need a while statement and some kind of counter, but i dont know how to do it. if anyone can even show me the simple prog maybe i could just study it and learn. ty |
![]() |
![]() |
|
![]() Administrator ![]() ![]() ![]() ![]() ![]() Joined Aug 23, '02 From Seattle, WA Currently Offline Reputation: 14 (100%) ![]() |
I know some Java. Basically, you could use java.util.Scanner's nextInt() function for accepting user input.
Then to print out all of the integers between the two numbers, you could do something like this: 1. Determine the smaller number(or if they're the same, in which case you'd output a message saying so.) 2. Increment your smaller number by one(So you don't include the user's entered number in your output.) 3. While the smaller number is less than the larger, print the smaller number and increment the smaller number by one. That's basically all you need to do. Shouldn't be too hard. ![]() -------------------- New Toyota project coming soon...
|
![]() |
|
Enthusiast ![]() Joined Feb 3, '04 From North Carolina Currently Offline Reputation: 0 (0%) ![]() |
QUOTE(Coomer @ Feb 14, 2006 - 4:11 AM) [snapback]393470[/snapback] I know some Java. Basically, you could use java.util.Scanner's nextInt() function for accepting user input. Then to print out all of the integers between the two numbers, you could do something like this: 1. Determine the smaller number(or if they're the same, in which case you'd output a message saying so.) 2. Increment your smaller number by one(So you don't include the user's entered number in your output.) 3. While the smaller number is less than the larger, print the smaller number and increment the smaller number by one. That's basically all you need to do. Shouldn't be too hard. ![]() yea i know what to do basically, i just cantactually do it lol but yea, ill keep trying. thankey This post has been edited by Celicaca: Feb 14, 2006 - 12:55 AM |
![]() ![]() |
Lo-Fi Version | Time is now: July 8th, 2025 - 4:50 AM |