im doing an assignment for java intro class and am getting the results i need just dont know if this is layed out right or not

here is what were supposed to do

Write a program that will read an unspecified number of positive numbers from the keyboard and determine the sum and the average of these numbers. A negative number should be used to terminate the input, i.e. when the program encounters a negative number, it should stop prompting and reading data and at that point should output the results. Note that the negative number that terminates the looping should not be added to the sum and certainly should not be counted as one of the valid numbers.

A sample program run would look like this :

Enter a number that is positive or zero 3

Enter a number that is positive or zero 5

Enter a number that is positive or zero 6

Enter a number that is positive or zero 4

Enter a number that is positive or zero -1

You have entered 4 numbers

Total of the numbers you entered is 18

Average of the numbers is 4.5

The program should use a WHILE loop to accomplish it's mission.

and here is my code

Code java:

Code java:

import java.util.Scanner ; public class Assign6_Roberts{ public static void main (String [] args){ //Create Scanner Scanner input = new Scanner(System.in); System.out.println("Enter a number that is positive or zero: "); int num = input.nextInt(); System.out.println("Enter a number that is positive or zero: "); int num1 = input.nextInt(); System.out.println("Enter a number that is positive or zero: "); int num2 = input.nextInt(); System.out.println("Enter a number that is positive or zero: "); int num3 = input.nextInt(); int sum = 0; System.out.println("You have entered 4 numbers "); System.out.println("Total of numbers is " + (num + num1 + num2 + num3)); System.out.println("Average of numbers is " + (num + num1 + num2 + num3) / 4); while (num <0){ sum+= num; } while (num <0){ sum/= num; } } } [B][/B]