简体   繁体   中英

Dividing by larger number first

    System.out.print("Enter the numbers here: ");
    Scanner gc = new Scanner(System.in);
    int firstNumber = gc.nextInt();
    int SecondNumber = gc.nextInt();

So that is the main part of my code. How could I divide the larger number by the smaller one easily, example if I put 1 for firstNumber and 2 for secondNumber how could I make it divide secondNumber by firstNumber.

System.out.print("Enter the numbers here: ");
Scanner gc = new Scanner(System.in);
int firstNumber = gc.nextInt();
int SecondNumber = gc.nextInt();
if(firstNumber>SecondNumber)
{
   firstNumber/SecondNumber;
}
else
   SecondNumber/firstNumber;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM