array exercise
jack chen
Posted in Java, on January 24, 2012 at 05:36
/*
 * A program that can store numbers and output the results
 *total numbers entered biggest and smallest number entered
 *and values entered most and least
 * 
 * Jack Chen
 * 19/1/12
 */ 

public class Array
{
	int store = 0;
	int[] array = new int[11];
	int total = 0;
	int t = -1;
	int big = 0;
	int small = 10;
	int most = 0;
	int less = 10;

	 public static void main(String[] args)
	 {
		 new Array(); 
	 }
	 public Array()
	 {
		 store = IBIO.inputInt("Please input a Array location: ");
		 
		 while (store != 0)
		 {
			 if (store != 0)
			 {
				 	if (small > store)
					{
						small = store;
					}
					
				 	if (big < store)
					{
						big = store;
					}
			 }
				 
			array[store] = array[store] + 1;
			store = IBIO.inputInt("Please input a Array location: ");
			total = total + 1;
		 }
		 
		 for (int z = 0; z < 11; z++)
			{
				IBIO.output("Input in array " + (t = t + 1) + " is: " + array[t]);
			}
				IBIO.output("Total values of number/s entered was: " + (total) + "\n" +
						"Biggest number entered was: " + big + "\n" +
						"Smallest number entered was: " + small + "\n" +
						"Values entered the most was/were: " + most + "\n" +
						"Values entered the least was/were: " + less
						);
				System.exit(0); 
			}
}

Share this code

| More

Use the link below to share the code:
HTML
BBCode