Hello there fellow Overflowers!
I'm getting started with Java and want to create a small program where it's possible to type in 5 numbers and get the sum and average printed out. The program runs and does it's job, but I feel that there must be a way smarter method / way then what I've done.
import java.util.Scanner;
public class Calc {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("5 random numbers");
int num1 = input.nextInt();
int num2 = input.nextInt();
int num3 = input.nextInt();
int num4 = input.nextInt();
int num5 = input.nextInt();
int sum = num1 + num2 + num3 + num4 + num5;
int avg = (num1 + num2 + num3 + num4 + num5)/5;
System.out.println("Sum is" + sum + " and the average is " + avg);```
Is it possible to declare all the numbers in one line or something?