In this post, you will get the solution to the first problem of Capgemini ADAPT Sprint 1 – JBR-CS5A-L2-2-LSAByCustomerName.

Note: The solutions are provided for learning purposes only.

## Sprint 1 – Problem 4: JBR-CS5A-L2-2-LSAByCustomerName:

### Problem Description:

Create a program to search the customer based on the customer’s Name using Linear Search Algorithm.

This program should print “No Record Found” if the name is not available in the given array.

Note: Use Linear Search Algorithm

Simrath

1002

Simrath

Amristar

King

No Record Found

10 seconds

## The solution to JBR-CS5A-L2-2-LSAByCustomerName:

```import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Source{
static String customerDetails[][] = new String [5][3];
static{
customerDetails[0][0] = "1001";
customerDetails[0][1] = "Raj";
customerDetails[0][2] = "Chennai";

customerDetails[1][0] = "1008";
customerDetails[1][1] = "Akshay";
customerDetails[1][2] = "Pune";

customerDetails[2][0] = "1002";
customerDetails[2][1] = "Simrath";
customerDetails[2][2] = "Amristar";

customerDetails[3][0] = "1204";
customerDetails[3][1] = "Gaurav";
customerDetails[3][2] = "Delhi";

customerDetails[4][0] = "1005";
customerDetails[4][1] = "Ganesh";
customerDetails[4][2] = "Chennai";
}
public static void main(String args[]) throws Exception{
Scanner sc = new Scanner(System.in);
String key = sc.nextLine();
int index = -1;
Boolean found = false;
int n = customerDetails.length;
for(int i = 0; i < n; i ++)
{
if(key.equalsIgnoreCase(customerDetails[i][1]))
{
found = true;
index = i;
break;
}
}
if(found)
{
for(int i = 0; i < 3; i++)
{
System.out.println(customerDetails[index[i]]))
}
}
else
{
System.out.println("No Record Found");
}
}
}

```

Pinterest
WhatsApp