CSC220-Lab 7 Arrays, Conditionals and Loops in Java Solved
Exercise arrays, conditionals and loops in Java.
Java programs:
Design and implement an application called Mean.java that computes and prints the mean of two lists of integers coming from the same list that has n numbers: x0, x1, …, xn-1. The first list L1 contains x0, x2, …, through xn-1 if n is odd or through xn-2 if n is even. The second list L2 contains x1, x3, …, through xn-1 if n is even or through xn-2 if n is odd. Ask the user to input n and read the value of n. Then ask the user to input n integers and save them in an array. Print out L1 and compute the mean as a floating point value for L1. Then print out L2 and compute the mean as a floating point value for L2, using the following formula:
Note:
Make sure you indent and comment your code based on the examples in the textbook. Don’t forget to include your name, the course number, title of the assignment, and today’s date.
Compiling and running Java programs (reminder):
1. Compile your program using the command javac filename
For example: java myProgram.java
If you receive errors during the compilation phase, re-edit the source code file and attempt to correct them.
Once a file successfully compiles, execute it using the java program. For example: java MyProgram