/    Sign up×
Community /Pin to ProfileBookmark

Basic Problem(Java101)

Hi:

Can anyone Hlep me please :
I have this program for school that i have to get working, i am starting to learn java and i am a little confuse. I need to make the user enter 5 numbers and then show the smallest.. This is what i have:

import java.util.Scanner;
public class Smaller {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
int c;
System.out.println(“How many numbers you wish to enter?”);
c = input.nextInt();
int n;

for (int counter = 1; counter<=c; counter++)
{
System.out.println(“Please Enter the next number”);
n = input.nextInt();

// need to compare with small here, update the smaller # to small

}
}
}

I need to get the second part right.. Thanks for your time!!
Regards
Ed

to post a comment
Java

2 Comments(s)

Copy linkTweet thisAlerts:
@OakNov 05.2005 — See attached.

All you really needed to do was check if each input was smaller than the last and store it in a separate variable.

[upl-file uuid=b75cd0f8-a5ad-4588-a576-deca5d4700e7 size=811B]SmallestNumber.zip[/upl-file]
Copy linkTweet thisAlerts:
@ed81authorNov 08.2005 — Thank you very much oak eventhough my professor said not to use constructor or new things but only those we have learned this is going to help me a million to understand it and try to create the program the way he wants it. I see your point.. someday i will be able to run programs the way you do ? .. I am just a newbie ?

Best Regards

Ed
×

Success!

Help @ed81 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...