The Artima Developer Community
Sponsored Link

Java Answers Forum
Array cell count

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Patti

Posts: 46
Nickname: patti
Registered: Feb, 2002

Array cell count Posted: Mar 21, 2002 6:07 PM
Reply to this message Reply
Advertisement
I need to add a way of counting how many of each input number is between 1-10, 11-20, 21-30, etc. and printing an * in the appropriate row. What do I need to add? Can I use the same array?

import java.io.*;
 
class Histogram {
	
	//----------------------------------------------------------
	// Program to display histogram of range of entered numbers.
	//----------------------------------------------------------
	
	public static int limit = 10;
	public static int number;
	private static BufferedReader stdin;
	public static int value = 0;
    public static int y;
	
	
	public static void main (String[] args) throws IOException{
 
		String [] list = new String [10];
		int [] range = new int [10];		
			
	   stdin = new BufferedReader (new InputStreamReader(System.in));
       System.out.println( "Enter 10 numbers between 1 and 100.");
     
     while (value != limit){ //sentinal to stop entering numbers
      
       for (int index = 1; index <= limit; index ++){
         System.out.print ("Enter " + (index) + ": ");
         number = Integer.parseInt (stdin.readLine()); 
         value++; 
         }
         System.out.println ("Done.");
         System.out.println(); 
       
         }
         
        
         
         // Loop to generate labels of rows
        for (int row = 0; row < list.length; row++){
           list[row] = (row * 10 + 1) + "- " + (row + 1) * 10;
           System.out.println (list[row] + " | ");
              
       }         
         
}//main method
}//class Histogram
 

Topic: Renderering Technology Previous Topic   Next Topic Topic: Java version of credit decision engine

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use