⌛ Counting the Mean

Learning outcomes

I will learn to write, compile and run a simple Maven based Java program.

The program is built using Maven. Place the pom.xml file in the round2/mean directory of your local repository and in this directory create the src/main/java subdirectory. You may name your classes freely, as long as your files are in the round2/mean/src/main/java directory. If you create your project with NetBeans, it’s recommended to leave the Package: field empty, to ensure the files are placed in the correct directory.

The program should first output the prompt Enter numbers: after which the numbers the mean is calculated from are given. The numbers must be given in a single line, separated by a space character (' '). The numbers are converted into double values, and the program prints out their mean in the form “Mean: x”, where x is the arithmetic mean of the numbers.

The automatic tests, and the ones given below, assume that you make the following definitions in your pom.xml project file:

  • The value of artifactId is mean.

  • The value of version is 1.0.

  • The values of the maven.compiler.source and maven.compiler.target elements are 17 or lower. The grader uses Java 17, so any newer versions won’t work.

  • A Onejar plugin definition where the value of mainClass element refers to the main class of your program, which you can name freely in this task. For example, if your main class is named Mean, the element value is Mean.

Example

The test compiles your program with the following command:

mvn package

If the compilation is successful the program is run with this command:

java -jar target/mean-1.0.one-jar.jar

The program outputs the prompt Enter numbers: after which the numbers which the mean is calculated from are given. In the first test the numbers are:

78.0625 73 92.125 47.0625 95.25 57.0625 28.25 37.125

The expected program output in the first test is:

Enter numbers:
Mean: 63.4921875

Submitting

Make sure before submission that your files are in the /round2/mean/ directory and that you have pushed the latest changes to your personal remote repository. When ready, enter the URL of your personal remote repository in the field below. The URL is https://course-gitlab.tuni.fi/compcs140-spring2024/------, where ------ denotes your Tampere university username.

A+ presents the exercise submission form here.

Posting submission...