English

A Class Teacher wants to keep the records of 40 students of her class along with their names and marks obtained in English, Hindi, Maths, Science and Computer Science in a Double Dimensional Array - Computer Applications

Advertisements
Advertisements

Question

A Class Teacher wants to keep the records of 40 students of her class along with their names and marks obtained in English, Hindi, Maths, Science and Computer Science in a Double Dimensional Array (DDA) as M[40][5].
When the teacher enters the name of a student as an input, the program must display the name, marks obtained in the 5 subjects and the total. Write a program in Java to perform the task.  

Answer in Brief

Solution

import java.util.*; 
class AQ18{
public static void main(String args[]){
Scanner ob = new Scanner(System.in);
int M[][] = new int[40][5];
String x, name[] = new String[40];
int i, j, tot = 0;

// INPUT LOOP
for (i = 0; i < 40; i++)
{System.out.print("Enter the name:");
name[i] = ob.next();

for (j = 0; j < 5; j++)
M[i][j] = ob.nextInt();
}

// SEARCH AND PRINT
System.out.println("SEARCH DETAILS");
System.out.println("Enter the name of the student");
x = ob.next();

System.out.println("English Hindi Math Sci Comp Total");
for (i = 0; i < 40; i++)
{if (!(name[i].equalsignoreCase(x))) // not equals
continue;

for (j = 0; j < 5; j++)
{System.out.print(M[i][j] + "\t");
tot += M[i][j];
}
System.out.print(tot);
break;
}
}}
shaalaa.com
  Is there an error in this question or solution?
Chapter 3: Arrays (Single Dimensional and Double Dimensional) - EXERCISES [Page 243]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 3 Arrays (Single Dimensional and Double Dimensional)
EXERCISES | Q VII. 18. | Page 243
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×