( --> )
Solution 2 to Typical First Challenge
<?PROGRAM> ->
// Prompt for three <int>s
IO.print("Enter three integers: ");
// Read the three s
int n1 = IO.read_int();
int n2 = IO.read_int();
int n3 = IO.read_int();
// Compute the maximum value
int max;
if ( n1 >= n2 )
{
if ( n1 >= n3 )
{
max = n1;
}
else
{
max = n3;
};
}
else
{
if ( n2 >= n3 )
{
max = n2;
}
else
{
max = n3;
};
}
// Compute the minimum value
int min;
if ( n1 <= n2 )
{
if ( n1 <= n3 )
{
min = n1;
}
else
{
min = n3;
};
}
else
{
if ( n2 <= n3 )
{
min = n2;
}
else
{
min = n3;
};
}
// Compute the desired difference
int diff = max - min;
// Print the desired difference
IO.println("The difference is: " + diff);