Skip to content

Instantly share code, notes, and snippets.

@PranavBhattarai
Last active June 13, 2019 13:49
Show Gist options
  • Save PranavBhattarai/50635485d7d8c33a04f5b590b0126f82 to your computer and use it in GitHub Desktop.
Save PranavBhattarai/50635485d7d8c33a04f5b590b0126f82 to your computer and use it in GitHub Desktop.
Print big and small number
package Day2;
import java.util.Scanner;
public class BigSmall {
int num1;
int num2;
int num3;
public void readNumber() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter number: ");
num1 = sc.nextInt();
System.out.println("Enter number: ");
num2 = sc.nextInt();
}
public void max() {
if (num1 > num2 && num1 > num3) {
System.out.println("Greatest number is: " + num1);
} else if (num2 > num1 && num2 > num3) {
System.out.println("Greatest number is: " + num2);
} else {
System.out.println("Greatest number is: " + num3);
}
public void min(){
if (num1 < num2 && num1 < num3) {
System.out.println("Smallest number is: " + num1);
} else if (num2 < num1 && num2 < num3) {
System.out.println("Smallest number is: " + num2);
} else {
System.out.println("Smallest number is: " + num3);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment