Question #281404

Write a program that read four taste values for ten studens store the value in two dimensional array display the content of the array in tabular format using for loop

Expert's answer



import java.util.Scanner;


public class App {


	/**
	 * The start point of the program
	 * 
	 * @param args
	 * 
	 */
	public static void main(String[] args) {
		int tasteValues[][] = new int[10][4];


		Scanner keyBoard = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println("Enter four taste values for student " + (i + 1));
			for (int j = 0; j < 4; j++) {
				System.out.print("Enter taste value " + (j + 1) + ": ");
				tasteValues[i][j] = keyBoard.nextInt();
			}
		}
		System.out.printf("%-18s", "");
		for (int j = 0; j < 4; j++) {
			System.out.printf("%s%-10d", "Taste ", (j + 1));
		}
		System.out.println();
		for (int i = 0; i < 10; i++) {
			System.out.printf("%s%-10d", "Student ", (i + 1));
			for (int j = 0; j < 4; j++) {
				System.out.printf("%-16d", tasteValues[i][j]);
			}
			System.out.println();
		}


		keyBoard.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS