Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-01-2008, 08:39 AM
Member
 
Join Date: May 2008
Posts: 3
thegross1 is on a distinguished road
number comparisson help
I've been working on this for a while and can't get it to work. Basically it's a program that stores sale amounts into an array. Then asks the user to enter an amount, then prints the sales people who exceeded the amount. Here is my for loop.

public void salesCompare()
{
for (int i=0; numCompare < this.sales[i]; i++)
{
System.out.println(this.sales[i]);

}
}//salesCompare()

numCompare is the user entered number and sales[] is obviously my array. When I run it, nothing happens. Any suggestions?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-01-2008, 09:01 AM
Zosden's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 386
Zosden is on a distinguished road
probably your numCompare is larger than sales[i];
__________________
My IP address is 127.0.0.1
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-01-2008, 09:25 AM
Member
 
Join Date: May 2008
Posts: 3
thegross1 is on a distinguished road
Nope.
I've been testing it with easy numbers. To test it I set sales[]=5.
sales[0]=1
sales[1]=2
.
.
.
sales[4]=5

numCompare=2

yet nothing prints
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-01-2008, 09:31 AM
Member
 
Join Date: May 2008
Posts: 3
thegross1 is on a distinguished road
Thanks for the response. I fixed by using the following:

public void salesCompare()
{
for (int i = 0; i< sales.length; i++)
{
if (numValue < sales[i])
System.out.println("Salesperson " +(i+1));
}
}//salesCompare()
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use Scanner with a number cew27 New To Java 8 01-29-2008 07:22 AM
line number kazitula New To Java 3 11-21-2007 11:27 PM
How to get next available number from MS access shahjehan Database 3 11-18-2007 08:41 PM
how to know the number of bytes gabriel New To Java 2 08-06-2007 06:13 PM
how to know the number of the line simon New To Java 3 08-01-2007 05:59 PM


All times are GMT +3. The time now is 07:36 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org