0% found this document useful (0 votes)
33 views3 pages

2.3 Ap Ankit

The document summarizes two experiments conducted on string manipulation in Java. The first experiment determines if a given sentence is a pangram by checking if it contains all letters of the alphabet. The second experiment counts the number of words in a string in CamelCase format by checking for capital letters. Both experiments use basic string and character operations like indexing, checking cases, etc. to solve the given problems in 3 steps - importing libraries, writing logic, printing output.

Uploaded by

Ankit Chaurasiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views3 pages

2.3 Ap Ankit

The document summarizes two experiments conducted on string manipulation in Java. The first experiment determines if a given sentence is a pangram by checking if it contains all letters of the alphabet. The second experiment counts the number of words in a string in CamelCase format by checking for capital letters. Both experiments use basic string and character operations like indexing, checking cases, etc. to solve the given problems in 3 steps - importing libraries, writing logic, printing output.

Uploaded by

Ankit Chaurasiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DEPARTMENT OF

COMPUTER SCIENCE&ENGINEERING

Experiment- 2.3
Student Name:Ankit Chaurasiya UID: 21BCS11172
Branch: CSE Section/Group: 604 A
Semester: 5th Date of Performance: 9/10/23
Subject Name: Advance Programming Lab-1 Subject Code: 21CSP-314

Aim: Demonstrate the concept of string.

Objective:
1. A pangram is a string that contains every letter of the alphabet. Given a sentence
determine whether it is a pangram in the English alphabet. Ignore case. Return
either pangram or not pangram as appropriate.
2. There is a sequence of words in CamelCase as a string of letters, s, having the
following properties:
• It is a concatenation of one or more words consisting of English letters.
• All letters in the first word are lowercase.
• For each of the subsequent words, the first letter is uppercase, and rest of the
letters are lowercase.
Given s, determine the number of words in s.

Script:
1. import java.io.*;
import java.util.*;

public class Solution {


public static boolean isPangram(String s) {
boolean[] isInside = new boolean[26];
for (char c : s.toCharArray()) {
if (Character.isLetter(c)) {
isInside[Character.toLowerCase(c)-'a'] = true;
DEPARTMENT OF
COMPUTER SCIENCE&ENGINEERING
}
}
for (boolean b : isInside) {
if (!b) return false;
}
return true;
}

public static void main(String[] args) {


Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
if (isPangram(s)) System.out.println("pangram");
else System.out.println("not pangram");
}
}
2.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

public static void main(String[] args) {


Scanner in = new Scanner(System.in);
String s = in.next();
int count = 1;
for(int i = 0; i<s.length(); i++){
char c = s.charAt(i);
if(c>='A' && c<='Z') count++;
}
System.out.println(count);
}
}
DEPARTMENT OF
COMPUTER SCIENCE&ENGINEERING
Output
1.

2.

You might also like