write a program in java to input and arrange 3 numbers in ascending order without using arrays/ functions.
Please be accurate and check the program before posting it.It's urgent
Ps. In 9th grade level
sp2003:
it should work for negative numbers also
Answers
Answered by
2
import java.util.*;
class TeraBhalaHo
{public static void main()
{Scanner Sc= new Scanner(System.in);
int a= Sc.nextInt();
int b=Sc.nextInt();
int c= Sc.nextInt();
if(a>b && a>c)
{if(b>c)
{System.out.println( c+ " " +b+ " "+a);
}
else
{System.out.println(b+ " " +c+ " " +a);
}
}
else if (b>a && b>c)
{if(a>c)
{System.out.println( c+ " " +a+ " "+b);
}
else
{System.out.println( a+ " " +c+ " "+b);
}
}
else
{if (b>a)
{System.out.println( a+ " " +b+ " "+c);
}
else
{System.out.println( b+ " " +a+ " "+c);
}
}
}
}
Hope it helps u...
If yes, mark brainliest...
have a gr8 day ahead...
@TeraBhalaHo
class TeraBhalaHo
{public static void main()
{Scanner Sc= new Scanner(System.in);
int a= Sc.nextInt();
int b=Sc.nextInt();
int c= Sc.nextInt();
if(a>b && a>c)
{if(b>c)
{System.out.println( c+ " " +b+ " "+a);
}
else
{System.out.println(b+ " " +c+ " " +a);
}
}
else if (b>a && b>c)
{if(a>c)
{System.out.println( c+ " " +a+ " "+b);
}
else
{System.out.println( a+ " " +c+ " "+b);
}
}
else
{if (b>a)
{System.out.println( a+ " " +b+ " "+c);
}
else
{System.out.println( b+ " " +a+ " "+c);
}
}
}
}
Hope it helps u...
If yes, mark brainliest...
have a gr8 day ahead...
@TeraBhalaHo
Similar questions