Java Programming about Arrays
Attachments:
Answers
Answered by
0
Answer:
import java.util.Scanner;
public class ActivityA {
public static void main (String [] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Please enter 7 numbers : ");
int num1 = sc.nextInt();
int num2 = sc.nextInt();
int num3 = sc.nextInt();
int num4 = sc.nextInt();
int num5 = sc.nextInt();
int num6 = sc.nextInt();
int num7 = sc.nextInt();
int[] arr = { num1, num2, num3, num4, num5, num6, num7 };
int maxNum = Math.max(num1, num2, num3, num4, num5, num6, num7);
int minNum = Math.min(num1, num2, num3, num4, num5, num6, num7);
System.out.println("The Largest value is : " + maxNum);
System.out.println("The Difference from the smallest is : "+(maxNum-minNum));
}
}
Similar questions