|
-
ARRAYS AGAIN????
I have tried to do this but I can not figure out how to get this. I
need to enter some values and put them in an array. and have those
values put in a range example is below, below that is my code I have
written so far. I can enter values but I can not figure out how to put
them in the correct cells in the array so that they add up to give me
the total in each price range. Confused yet? I am!
Arrays are driving me nuts! Please I just need some advice to get me
in the right direction. Thank you.
ranges HOW MANY SALEPEOPLE IN EACH RANGE
$0-99 ---------------- 1
$100-199 ---------------- 2
$200-299 ---------------- 1
$300-399 ---------------- 3
$400-499 ---------------- 1
$500-599 ---------------- 0
$600-699 ---------------- 2
$700-799 ---------------- 0
$800-899 ---------------- 2
$900-999 ---------------- 0
$1000+ ---------------- 1
This program has got me all confused if there is anyone with
some suggestions please feel free.
---------------------------------------------------------------------------
import javax.swing.*;
public class range
{
public static void main( String[] args )
{
int gross = 0;
String output;
int[] total = new int[10];
while( gross != -1)
{
String input = JOptionPane.showInputDialog(null, " Enter
The Gross Sales Amount, -1 to quit" );
gross = Integer.parseInt( input );
if ( gross <= 299 )
total[0]+=total[0]++;
if ( gross <= 399 )
total[1]+=total[1]++;
}
output = "$200-$299 " + total[0] +
"\n$300-$399 " + total[1];
JOptionPane.showMessageDialog(null, output,"gross salaries ",
JOptionPane.INFORMATION_MESSAGE );
System.exit( 1 );
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks