# Capgemini ADAPT 2022 – Count Character Frequency Problem Solution using Java

In this post, we will try to give a solution to an important problem of Capgemini ADAPT 2022. The solution to the Problem is – Count Character Frequency Solution using Java.

However, the solutions are provided for learning purposes only. Candidates must submit their own code during attending the Sprints.

### Count Character Frequency Problem Description – Capgemini ADAPT:

Write a program in Java to accept a string. Count and display the frequency of each character present in the string. The character with multiple frequencies should be displayed only once.

### Count Character Frequency Problem Solution:

import java.util.Scanner;

public class Source {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println(“Enter a string:”);
String str = in.nextLine();
int len = str.length();
char seenArr[] = new char[len];
int freqArr[] = new int[len];
int idx = 0;

for (int i = 0; i < len; i++) {
char ch = str.charAt(i);

if (Character.isWhitespace(ch)) {
continue;
}

boolean seen = false;
for (int j = 0; j < idx; j++) {
if (ch == seenArr[j]) {
seen = true;
break;
}
}

if (seen) {
continue;
}

int f = 1;
for (int k = i + 1; k < len; k++) {
if (ch == str.charAt(k)) {
f++;
}
}

seenArr[idx] = ch;
freqArr[idx] = f;
idx++;
}

for (int i = 0; i < idx; i++) {
System.out.print(seenArr[i] + ” “);
}

System.out.println();
for (int i = 0; i < idx; i++) {
System.out.print(freqArr[i] + ” “);
}
}
}

### Top Companies + Batchwise Hiring Drive:

 TOP COMPANIES HIRING DRIVE BATCHWISE HIRING DRIVES 1. TCS OFF-CAMPUS DRIVES 1. 2018 BATCH 2. INFOSYS OFF-CAMPUS DRIVES 2. 2019 BATCH 3. COGNIZANT OFF-CAMPUS DRIVES 3. 2020 BATCH 4. WIPRO OFF-CAMPUS DRIVES 4. 2021 BATCH 5. CAPGEMINI OFF-CAMPUS DRIVES 5. 2022 BATCH

### Capgemini ADAPT Sprint 1 (Bus Reservation Solutions):

• 1. Capgemini ADAPT Sprint 1 Bus Reservation System – DisplayCustomerInAscendingOrder Problem Solution
• 2. Capgemini ADAPT Sprint 1 Bus Reservation System – DisplayCustomerByFirstName Problem Solution
• 3. Capgemini ADAPT Sprint 1 Bus Reservation System – SortByCustomerId Problem Solution
• 4. Capgemini ADAPT Sprint 1 Solution Java | LSAByCustomerName Problem Solution
• 5. Capgemini ADAPT Sprint 1 Case Study Solution Java | BSAByCustomerId Problem Solution

### Capgemini ADAPT Sprint 2 (Bus Reservation System):

• 1. Capgemini ADAPT Sprint 2 Case Study (Bus Reservation System) Solution | HAS-A-Relationship Solution Java
• 2. Capgemini ADAPT Sprint 2 Case Study (Bus Reservation System) Solution OOPs-Para-Constructor Java
• 3. Capgemini ADAPT Sprint 2 Bus Reservation System (CRUDOperations) Problem Solution

### Online Shopping A Solutions Using Java:

• 1. Capgemini ADAPT 2022 Online Shopping A – Display Products Solution using JAVA – Click Here
• 2. Capgemini ADAPT 2022 Online Shopping A – Products by Category Solution using JAVA – Click Here
• 3. Capgemini ADAPT 2022 Online Shopping A – Customer Array Solution using JAVA – Click Here
• 4. Capgemini ADAPT 2022 Online Shopping A – Search Customers by Name Solution using JAVA – Click Here
• 5. Capgemini ADAPT 2022 Online Shopping A – Search Customers by City Solution using JAVA – Click Here