
March 7th, 2013, 10:07 AM
|
|
Registered User
|
|
Join Date: Mar 2013
Posts: 1
Time spent in forums: 2 m 47 sec
Reputation Power: 0
|
|
|
Homework - Help please
i need to output the index for the lowest value and now all i am able to output is [0][1] im not sure why
class Arrayed
{
public static void main( String [] args )
{
double [] [] temp = { { 43, 3},
{ 50, 6 },
{ 66, 32},
{ 68, 40},
{ 75, 55},
{ 88, 50},
{ 90, 66},
{ 98, 65},
{ 85, 50},
{ 76, 43},
{ 65, 42},
{ 52, 15} };
String [] string = { "high", "low", };
for( int i = 0; i < string.length; i++ )
System.out.println( " string " + i + " : "
+string[i] );
Scanner scan = new Scanner( System.in );
int currentLow;
do
{
System.out.print( "Enter 1 for low > " );
currentLow = scan.nextInt( );
} while ( currentLow < 0 || currentLow > 1 );
double indexLowTemp = temp[0][currentLow];
for ( int i = 1; i > temp.length; i++ ) { if ( currentLow < temp[i].length )
{
if ( temp[i][currentLow] > indexLowTemp )
indexLowTemp = temp[i][currentLow];
}
}
System.out.println ( "\nThe min temp for " + string[currentLow] + " is " +( indexLowTemp ) );
}
}
|