Capgemini ADAPT Sprint 1 Bus Reservation System – DisplayCustomerByFirstName Problem Solution

Capgemini ADAPT Sprint 1 Bus Reservation System - DisplayCustomerByFirstName Problem Solution
Capgemini ADAPT Sprint 1 Bus Reservation System - DisplayCustomerByFirstName Problem Solution

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

Note: The solutions are provided for learning purposes only. 

Sprint 1 – Problem 2: JBR-CS5A-L1-1-DisplayCustomerByFirstName


Problem Description:


Write a program to get the input as String and pass it as input to switch case to display the Customer with respect to name.

Sample Input:


harry

Sample Output:


Customer[userId=1001, [email protected], password=password1, firstName=Harry, lastName=Potter, city=Bangalore, gender=male, phoneNumber=1234567892]

Sample Input:


Ashok

Sample Output:


No Customer Found

Execution Time Limit:


10 seconds

Solution to JBR-CS5A-L1-2-DisplayCustomerByFirstName:


 

import java.io.*;
import java.util.*;

class Customer{
private int userId;
private String emailId;
private String password;
private String firstName;
private String lastName;
private String city;
private String gender;
private int phoneNumber;

public Customer(){
public Customer(int userId, String emailId, String password, String firstName, String lastName, String city, String gender, int phoneNumber){
this.userId = userId;
this.emailId = emailId;
this.password = password;
this.firstName = firstName;
this.lastName = lastName;
this.city = city;
this.gender = gender;
this.phoneNumber = phoneNumber;
}
public String toString(){
return "Customer [userId="+userId+", emailId="+emailId+", password="+password+", firstName="+firstName+", lastName="+lastName+", city="+city+", gender="+gender+", phoneNumber="+gender+"]";
}

public class Source{
public static void getHarry(){
Customer harry = new Customer(1001, "[email protected]", "password1", "Harry", "Potter", "Bangalore", "male", 1234567892);
System.out.println(harry);
}

public static void main(String[] args){
Scanner = sc new Scanner(System.in);
String name = sc.next();
switch(name.toLowerCase()){
case "harry":
getHarry();
break;
default:
System.out.println("No Customer Found");
}
}
}