Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MyClass {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter how many numbers you want to compare: ");
- int n = sc.nextInt();
- int max = Integer.MIN_VALUE;
- for (int i = 1; i <= n; i++) {
- System.out.print("Enter number " + i + ": ");
- int x = sc.nextInt();
- if (x > max) {
- max = x;
- }
- }
- System.out.println("The maximum number is: " + max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement