Two dimensional array Learn programming Java

Lesson:

Arrays, Structures and Strings


Exercise:

Two dimensional array


Objetive:

Write a java program to ask the user for marks for 20 pupils (2 groups of 10, using a two-dimensional array), and display the average for each group.


Code:

import java.util.*;
public class Main
{
	public static void main()
	{
		float[][] puntuations = new float[10][10];
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < 10; j++)
			{
				System.out.printf("Enter the puntuation %1$s group %2$s: " + "\r\n", j + 1, i + 1);
				puntuations[i][j] = Float.parseFloat(new Scanner(System.in).nextLine());
			}
		}
	}
}

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.