import java.util.Scanner;
public class NumberAverager {
/**
* Averages Inputted Numbers
*/
public static void main(String[] args) {
int num1;
int total = 0;
int count = 0;
//int[] numArray = new int[count];
String input;
Scanner keyboard = new Scanner(System.in);
do
{
if (count == 0)
{
System.out.println("Please enter the first number you wish to average.");
input = keyboard.nextLine();
}
count++;
System.out.println("Please enter your next number or 'calculate' to find the average.");
input = keyboard.nextLine();
try
{
num1 = Integer.parseInt(input);
total = total + num1;
//numArray[count]=num1;
}
catch (NumberFormatException e)
{
System.out.println("You entered " + count + " numbers.");
System.out.println("The average is " + (float)total/count);
//System.out.println(numArray[count]);
input = "calculate";
}
} while (input!= "calculate");
keyboard.close();
}
}
There's my program if that helps,
The manifest says the following:
Manifest-Version: 1.0
Main-Class: NumberAverager
It's just a short program to try to do this, but I don't know what else I have to do to make it work, I'm not sure how to run it from the command line to try it that way, and upon double clicking it the mouse loads for a second and nothing happens
thanks
I'm very new to java, only a beginning semester under my belt, so I need very detailed explanations on how to do this, thanks again