English

A Metropolitan Hotel has 5 floors and 10 rooms in each floor. The names of the visitors are entered in a Double Dimensional Array (DDA) as M[S][lO]. The Hotel Manager wants to know from the "Enquiry" - Computer Applications

Advertisements
Advertisements

Question

A Metropolitan Hotel has 5 floors and 10 rooms in each floor. The names of the visitors are entered in a Double Dimensional Array (DDA) as M[S][10].
The Hotel Manager wants to know from the "Enquiry" about the position of a visitor (i.e. floor number and room number) as soon as he enters the name of the visitor. Write a program in Java to perform the above task. 

Answer in Brief

Solution

import java.util.*;
class AQ17
{public static void main(String args[])
{Scanner ob = new Scanner(System.in);
inti;
String name = "";
String m[][] = new String[5][10];
System.out.println("Enter the names of the customers");
for (i = 0; i < 5; i++)
{for (j = 0; j < 10; j++)
m[i][j] = ob.nextLine();
}
System.out.println("***Enquiry for Floor, Room Number***");
System.out.println("Enter the name of the customer");
name = ob.nextLine();
for (i = 0; i < 5; i++)
{for (j = 0; j < 10; j++)
{if (m[i][j].equalsIgnoreCase(name))
System.out.println("Floor: " + (i + 1) + "\t" + "Room: " + (j + 1));
}
}}}
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. 17. | Page 243
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×