Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ArrStat {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- System.out.println("Input numbers: ");
- String text = scan.nextLine();
- String [] splitText = text.split(" ");
- int min = Integer.MAX_VALUE;
- int max = Integer.MIN_VALUE;
- double sum =0;
- double avg = 0;
- for (int i = 0; i < splitText.length; i++) {
- int CurrentSum = Integer.parseInt(splitText[i]);
- sum+=CurrentSum;
- if (CurrentSum > max){
- max = CurrentSum;
- }else if(CurrentSum < min){
- min = CurrentSum;
- }
- }
- avg = sum/splitText.length;
- System.out.println("Min: " + min + " Max: " + max + " Sum: " + sum + " Average: " + avg);
- }
- }
Add Comment
Please, Sign In to add comment