Array Program
Posted in Java, on January 24, 2012 at 19:56
/**
*Adam Khazi, Array Program.
*/
public class arrayprog
{
public static void main(String[] args)
{
new arrayprog();
}
public arrayprog()
{
int[] freqarray = new int [100];
int i = 0;
int Num = 10;
int Num1 = 1;
int mused = 1;
int musedcounter = 1;
int lused = 1;
int greatest = 1;
int lowest = 10;
while (Num != 0) {
i = i + 1;
Num = IBIO.inputInt("Enter Number: ");
if (Num > greatest) {
greatest = Num;
}
if (Num < lowest && Num != 0) {
lowest = Num;
}
//if (numbers[index] > lowest) {
//lowest = numbers[index];
//}
freqarray[Num] = freqarray[Num]+1 ;
}
Num = 2;
for(int a=1; a<11; a++) {
if (freqarray[greatest] > freqarray[Num]) {
mused = freqarray[Num];
Num = Num +1;
greatest = greatest +1;
}
}
//while (Num == 0) {
//System.exit(0);
//IBIO.output ("ZOMG I End");
//}
int s = 1; //visual output
int total = i;
total = total - 1;
Num = 1;
for(int a=1; a<11; a++) {
IBIO.output (s + ": " + freqarray[Num] );
Num = Num + 1;
s = s+1;
}
IBIO.output("Total number of values entered was: "+ total);
IBIO.output("The greatest number inputted was " + greatest);
IBIO.output("The lowest number inputted was " + lowest);
IBIO.output("The number inputted the most was " + mused);
}
}
Share this code
Use the link below to share the code:
http://www.codesend.com/view/83b2a2fe6bb663e513e01d9df43d7e87/
HTML
<a href="http://www.codesend.com/view/83b2a2fe6bb663e513e01d9df43d7e87/">Array Program</a>
BBCode
[url=http://www.codesend.com/view/83b2a2fe6bb663e513e01d9df43d7e87/]Array Program[/url]
© 2010 CodeSend.com - send code quick and easy
Syntax highlighting by Alex Gorbatchev
Syntax highlighting by Alex Gorbatchev
