hasta mi final il divo-arreglos partes cuarteto de cuerdas
Descripción: This sheet fot quartet strings for violin 1 and 2, viola, and cello
This sheet fot quartet strings for violin 1 and 2, viola, and cello
Descripción: String quartet arrangement
String quartet arrangement
String quartet arrangement
assembly language program for performing the string manipulation operations in 8086 microprocessor string can be manipulated on bit by bit AND , OR, NOT operation
String Art
Descripción: violin tutorials
De Samuel Applebaum. Es un libro de método para violín para los de nivel iniciadoDescripción completa
Descripción: String Quartet-MIDI mockup
string h
String Quartet Moon River String Quartet ScoreDescripción completa
Descrição completa
Descripción: Schubert
Descripción: One-position arpeggios for common chords, written for the 4-string electric bass. Please note that the patterns are written with the E-string on the bottom.
Full description
String Trio Winter
string quartetDescrição completa
2. Number Validation Write Write a program to read a string of 10 digit number , check whether the string contains a 10 digit number in the format XXX-XXX-XXXX where 'X' is a digit.
Include a class UserMainCode with a static method validateNumber which accepts a string as input . The return return tpe of the output should be 1 if the string meets meets the abo!e speci"ed format . In case the number does not meet the speci"ed format then return -1 as output. #reate a class Main which would get the input as a $tring of numbers and call the static methodvalidateNumber present in the %ser&ain#ode. Input and Output Format: Input consists of a string. utput is a string specifing the gi!en string is !alid or not . (efer (efer sample output for formatting speci"cations. Sample Input 1: 1)*-+-/ Sample Output 1: alid number format Sample Input 2: -1)*-1)*++*)) Sample Output 2: In!alid number format java.util.Scanner; importjava.util.Scanner; import
String n1*in.ne,t-ine(); (n1); int c*UserMainCode.validateNumber (n1); int c*UserMainCode. (c**1) if(c**1) if S+stem.out.rintln("/-0" .rintln("/-0"); ); else S+stem.out.rintln("0N/-0" .rintln("0N/-0"); );
& &
4.
Fetcin! Middle Caracters "rom Strin!
Write Write a program to read a string of e!en length and to fetch two middle most characters from the input string and return it as string output. Include a class UserMainCode with a static method !etMiddleCars which accepts a string of e!en length as input . The return tpe is a string which should be the middle characters of the string. #reate a class Main which would get the input as a string and call the static method !etMiddleCars present in the %ser&ain#ode. Input and Output Format: Input consists of a string of e!en length. utput is a string . (efer (efer sample output for formatting speci"cations. Sample Input 1: this Sample Output 1: hi Sample Input 1: 2ell Sample Output 1: el java.util.Scanner; importjava.util.Scanner; import
UserMainCode { publicclass publicc lassUserMainCode 22 2 @param args args 2 getMiddleChars(String s1) getMiddleChars(String staticvoid { 3*s1.length(); int 3*s1.length(); int mid*34; int mid*34; int String5u66ersb1* new String5u66er(); newString5u66er();
String n1*in.ne,t-ine(); (n1); int c*UserMainCode.validateNumber (n1); int c*UserMainCode. (c**1) if(c**1) if S+stem.out.rintln("/-0" .rintln("/-0"); ); else S+stem.out.rintln("0N/-0" .rintln("0N/-0"); );
& &
4.
Fetcin! Middle Caracters "rom Strin!
Write Write a program to read a string of e!en length and to fetch two middle most characters from the input string and return it as string output. Include a class UserMainCode with a static method !etMiddleCars which accepts a string of e!en length as input . The return tpe is a string which should be the middle characters of the string. #reate a class Main which would get the input as a string and call the static method !etMiddleCars present in the %ser&ain#ode. Input and Output Format: Input consists of a string of e!en length. utput is a string . (efer (efer sample output for formatting speci"cations. Sample Input 1: this Sample Output 1: hi Sample Input 1: 2ell Sample Output 1: el java.util.Scanner; importjava.util.Scanner; import
UserMainCode { publicclass publicc lassUserMainCode 22 2 @param args args 2 getMiddleChars(String s1) getMiddleChars(String staticvoid { 3*s1.length(); int 3*s1.length(); int mid*34; int mid*34; int String5u66ersb1* new String5u66er(); newString5u66er();
(374**!) if(374**!) if { sb1.aend(s1.chart(mid1)); sb1.aend(s1.chart(mid)); & S+stem.out.rintln(sb1); & main(String$ args) { main(String$ publicstaticvoi publicst aticvoid d TODO utogenerated method stub TODO utogenerated Scanner in*new in*newScanner(S+stem. Scanner(S+stem.in); String n1*in.ne,t-ine(); UserMainCode.getMiddleChars(n1); & &
#. Cec$ Caracters in a Strin! Write Write a program to read read a string and to test whether "rst and last last character are same. The string is said to be be !alid if the 1st and last character are the same. 3lse the string is said to be in!alid.
Include a class UserMainCode with a static method cec$Caracters which accepts a string as input . The return return tpe of this method is an int. utput should be 1 if the "rst character and last character are same . If the are di4erent di4erent then return -1 as output. #reate a class Main which would get the input as a string and call the static method cec$Caracterspresent in the %ser&ain#ode. Input and Output Format: Input consists of a string. utput is a string saing characters are same or not . (efer (efer sample output for formatting speci"cations. Sample Input 1: the picture was great Sample Output 1: alid Sample Input 1: this Sample Output 1: In!alid java.util.Scanner; importjava.util.Scanner; import
%. Formin! Ne& 'ord "rom a Strin! Write a program to read a string and a positi!e integer n as input and construct a string with "rst n and last n characters in the gi!en string.
Include a class UserMainCode with a static method "ormNe&'ord which accepts a string and positi!e integer . The return tpe of the output should be a string 5!alue6 of "rst n character and last n character. #reate a class Main which would get the input as a string and integer n and call the static method"ormNe&'ord present in the %ser&ain#ode. Input and Output Format: Input consists of a string of e!en length. utput is a string . 7ote8 The gi!en string length must be 9:)n. (efer sample output for formatting speci"cations. Sample Input 1: #alifornia * Sample Output 1: #alnia
Sample Input 2: this 1 Sample Output 2: Ts importjava.util.Scanner;
11. Strin! (ncr)ption ;i!en an input as string and write code to encrpt the gi!en string using following rules and return the encrpted string8
1. (eplace the characters at odd positions b ne' replace it b 'a'. - ?ssume the "rst character in the string is at position 1. Include a class UserMainCode with a static method encr)pt which accepts a string. The return tpe of the output is the encrpted string.
#reate a Main class which gets string as an input and call the static method encr)pt present in theUserMainCode. Input and Output Format: Input is a string . utput is a string. Sample Input 1: curiosit Sample Output 1: dusips@t> Sample Input 2: >>>> Sample Output 2: ?>a> importjava.util.Scanner;
G ag:1F brea$ F L L i" 5ag::06 return 1F return )F L public static void main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F $tring s1:in.ne
-.,everse Split Write a program to read a string and a character, and re!erse the string and con!ert it in a format such that each character is separated b the gi!en character. rint the "nal string. Include a class UserMainCode with a static method resape which accepts a string and a character. The return tpe 5$tring6 should return the "nal string. #reate a #lass &ain which would be used to accept a string and a character, and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of a string and a character. utput consists of a string 5the "nal string6. (efer sample output for formatting speci"cations. Sample Input: (abbit Sample Output: t-i-b-b-a-( publicclass %ser&ain#ode G publicstatic $tring reshape5$tring s1,car c6 G int iF $tringHu4er sb1:ne& $tringHu4er56F "or5i:s1.length56-1Fi9:0Fi--6 G sb1.append5s1.char?t5i66.append5c6F L sb1.delete#har?t5sb1.length56-16F
return sb1.to$tring56F L publicstaticvoid main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F $tring s1:in.ne
1/.ast etters Write a program to read a sentence as a string and store onl the last letter of each word of the sentence in capital letters separated b C. rint the "nal string.
Include a class UserMainCode with a static method !etastetter which accepts a string. The return tpe 5string6 should return the "nal string. #reate a #lass &ain which would be used to read a string, and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of a string. utput consists of a string 5the "nal string6. (efer sample output for formatting speci"cations. Smaple Input : This is a cat Sample Output : $C$C?CT import @a!a.util.$cannerF
publicclass %ser&ain#ode G publicstatic $tring get=ast=etter5$tring s16 G $tringTokeni>er st:ne& $tringTokeni>er5s16F $tringHu4er sb1:ne& $tringHu4er56F &ile5st.has&oreTokens566G $tring str:st.ne
return sb1.to$tring56F
L publicstaticvoid main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F $tring s1:in.ne
12.?ll Numbers
Write a program to read a string arra and return 1 if all the elements of the arra are numbers, else return -1. Include a class %ser&ain#ode with a static method validateNumber which accepts a string ara. The return tpe 5integer6 should be -1 or 1 based on the abo!e rules. #reate a #lass &ain which would be used to accept Input string arra and call the static method present in %ser&ain#ode. The string arra is said to be !alid if all the elements in the arra are numbers. 3lse it is in!alid. Input and Output Format: Input consists of an integer specifing the si>e of string arra followed b n strings. (efer sample output for formatting speci"cations. Sample Input 1: + 1)* )+. )* one Sample Output 1: in!alid Sample Input 2: ) 1)* )+. Sample Output 2: import @a!a.util.$cannerF publicclass %ser&ain#ode G publicstatic $tring !alidate7umber5$tring s1NO, int n6 G int l:0F "or5int i:0FinFiJJ6 G i" 5s1NiO.matches5N0-.OQ66
JJlF L i" 5l::n6 return!alidF returnin!alidF
L publicstaticvoid main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F int n:Integer. parseInt 5in.ne
14.Ma5 Substrin!
Write a program to accept two string inputs. The "rst being a source string and second one a delimiter. The source string contains the delimiter at !arious locations. ^our @ob is to return the substring with mae of the delimiter is 1. Include a class %ser&ain#ode with a static method e5tractMa5 which accepts the string. The return tpe 5string6 should be the ma< substring. #reate a #lass &ain which would be used to accept Input string and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of a source string and delimiter. utput consists of a string. (efer sample output for formatting speci"cations. Sample Input 1: delhi-pune-patna Sample Output 1: Eelhi\ import @a!a.util.$cannerF import @a!a.util.$tringTokeni>erF publicclass %ser&ain#ode G publicstatic $tring eer st:ne& $tringTokeni>er5s1,s6F int ma<:0F &ile5 st.has&oreTokens566 G
$tring s*:st.ne
1#.States and Capitals
Write a program that construts a hashmap with ZstateS as ke and ZcapitalS as its !alue. If the nee of the hashmap. The ne
class $ample G static $tring displa52ash&ap$tring,$tring9 hm,$tring s*6 G $tring str:F $tring res:F $tring str1:F "or5&ap.3ntr$tring,$tring9 map8hm.entr$et566 G str1:map.get_e56F i" 5s*.e[uals5str166 G str:map.getalue56F brea$ F L
L res:strJCJstr1F return res.to=ower#ase56F L L public class %ser&ain#ode G public static void main5$tring sNO6 G 2ash&ap$tring,$tring9 l:ne& 2ash&ap$tring,$tring956F $canner sc:ne& $canner5$stem.in6F int n:sc.ne
1%.Simple Strin! Manipulation < II
Write a program to read a string and return an integer based on the following rules. If the "rst word and the last word in the $tring match, then return the number of characters in the word else return sum of the characters in both words. ?ssume the $trings to be case - sensiti!e. Include a class %ser&ain#ode with a static method calculate'ordSum which accepts a string. The return tpe 5integer6 should be based on the abo!e rules. #reate a #lass &ain which would be used to accept Input string and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string with mae of 100 characters. utput consists of a string. (efer sample output for formatting speci"cations. Sample Input 1: #;7IY?7T T3#27=;^ $=%TI7$ #;7IY?7T Sample Output 1: Sample Input 2: 2W ?(3 ^% Sample Output 2: import @a!a.util.$cannerF publicclass %ser&ain#ode G staticint !alidate7umber5$tring s16 G int a:s1.inde<f5 6F int b:s1.lastInde<f5 6F $tring s:s1.substring50,a6F $tring s):s1.substring5bJ16F i" 5s.e[uals5s)66 return s.length56F return 5s.length56Js).length566F L publicstaticvoid main5$tringNO args6 G RR OO ?uto-generated method stub $canner in:ne& $canner5$stem.in6F $tring n1:in.ne
L L
22.Valid ate
;i!en a date string as input, write a program to !alidate if the gi!en date is in an of the following formats8 dd.mm. ddRmmR dd-mm- Include a class UserMainCode with a static method Zvalidateate S that accepts a $tring and returns an integer. This method returns 1 if the date is !alid, else return -1. #reate a class Main which would get a $tring as input and call the static method validateate present in the %ser&ain#ode.
Input and Output Format: Input consists of a $tring. utput consists of a $tring that is either 'alid' or 'In!alid'. Sample Input 1: 1).0*.)01) Sample Output 1: alid Sample Input 2: )B01B1 Sample Output 2: In!alid @a!a.te
$impleEatePormatsdf $impleEatePormatsdf : ne&$impleEatePormat5 dd-&&- dd-&&-6F 6F $impleEatePormat $impleEatePormat sdf1 : ne&$impleEatePormat5ddR&&R $impleEatePormat5ddR&&R6F 6F $impleEatePormat $impleEatePormat sdf) : ne&$impleEatePormat5dd.&&. $impleEatePormat5dd.&&.6F 6F $tring s1F sdf.set=enient5 "alse6F sdf1.set=enient5"alse6F sdf).set=enient5"alse6F tr) G Eate d1:sdf.parse5str6F !alidFF return!alid L catc5arse3
G Eate d*:sdf).parse5str6F !alidFF return!alid L catc5arse3
2+.Convert Format import @a!a.util.$cannerF import @a!a.util.$tringTokeni>erF publicclass %ser&ain#ode G con!ertPormat5$tring s6 publicstatic $tring con!ertPormat5$tring G $tringTokeni>er $tringTokeni>er t:ne& $tringT $tri ngTokeni>er5s, okeni>er5s,- -6F 6F $tring s1:t.ne
$tringHu4er sb:ne& $tringHu4er56F sb.append5s1.substring50, sb.append5s1.substring 50, s1.length56-166.append s1.length56-166.append55 '-' '-'6F 6F sb.append5s1.char?t5s1.length56-166.append5s).char?t5066.append5 '-' '-'6F 6F sb.append5s).substring51, sb.append5s).substring 51, s).length5666.append5 s).length5666.append5s*.char?t5066.append5 s*.char?t5066.append5'-' '-'6F 6F sb.append5s*.substring51, sb.append5s*.substring 51, s*.length5666F return sb.to$tring56F
L publicstaticvoid main5$tringNO args6 G $canner in:ne& $canner5$stem. in6F $tring str:in.ne
20.Strin! Occurances < II
btain two strings $1,$) from user as input. ^our ^our program should count the number of times $) appears in $1. (eturn (eturn the count as output. 7ote - #onsider case. Include a class %ser&ain#ode with a static method !etSubstrin! which accepts two string !ariables. The return tpe is the count. #reate a #lass &ain which would be used to accept two Input strings and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of two strings with mae of 100 characters. utput consists of an integer. (efer (efer sample output for formatting speci"cations. Sample Input 1: catcowcat cat Sample Output 1: )
Sample Input 2: catcowcat #?T #?T Sample Output 2: 0 import @a!a.util.$cannerF publicclass %ser&ain#ode G staticint !alidate7umber5$tring s1,$tring n6 G $tring s:s1.replace5n, s:s1.replace5n,C C6F 6F int l:0F i:0Fis.length56FiJJ6 "or5int i:0Fis.length56FiJJ6 5s.char?t5i6::'C'66 i" 5s.char?t5i6::'C' JJlF return lF L publicstaticvoid main5$tringNO args6 G
RR OO ?uto-generated method stub $canner in:ne& $canner5$stem.in6F $tring n1:in.ne
L L
+2.,epeat Front
;i!en a string 5s6 and non negati!e integer 5n6 appl the following rules. 1. ).
Eispla the "rst three characters as front. If the length of the string is less than *, then consider the entire string as front and repeat it n times.
Include a class %ser&ain#ode with a static method repeatFirstreeCaracters which accepts the string and integer. The return tpe is the string formed based on rules. #reate a #lass &ain which would be used to accept the string and integer and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string and integer. utput consists of a string . (efer sample output for formatting speci"cations. Sample Input 1: #oward ) Sample Output 1: #ow#ow
Sample Input 2: $o *
Sample Output 2: $o$o$o import @a!a.util.$cannerF publicclass %ser&ain#ode G publicstatic $tring con!ertPormat5$tring s,int n6 G
$tringHu4er sb:ne& $tringHu4er56F "or5int i:0FinFiJJ6 G i" 5s.length56*6 sb.append5s6F else sb.append5s.substring50,*66F L return sb.to$tring56F
L publicstaticvoid main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F $tring str:in.ne
++.Sorted ?rra)
Write a program to read a string arra, remo!e duplicate elements and sort the arra. 7ote8 1.
The check for duplicate elements must be case-sensiti!e. 5?? and aa are 7T duplicates6
).
While sorting, words starting with upper case letters takes precedence.
Include a class %ser&ain#ode with a static method order(lements which accepts the string arra. The return tpe is the sorted arra. #reate a #lass &ain which would be used to accept the string arraand integer and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of an integer n which is the number of elements followed b n
string !alues. utput consists of the elements of string arra. (efer sample output for formatting speci"cations. Sample Input 1: ??? HHH ??? ??? ### ### Sample Output 1: ??? HHH ###
Sample Input 2: ??? HHH aaa ??? ?bc ? b Sample Output 2: ? ??? ?bc HHH aaa b import @a!a.util.QF public class %ser&ain#ode G public static $tringNO order3lements5$tringNO arr6 G 2ash$et$tring9 al: ne& 2ash$et$tring956F "or5int i:0Fiarr.lengthFiJJ6
G
L
al.add5arrNiO6F L Iterator$tring9 itr:al.iterator56F arr : ne& $tringNal.si>e56OF int i :0 F &ile5itr.has7e
L public static void main5$tringNO args6 G int nF $canner in : ne& $canner5$stem.in6F n : in.ne
L
+4.*attern Matcer
Write a program to read a string and check if it complies to the pattern '#TXXXXXX' where XXXXXX is a digit number. If the pattern is followed, then print T(%3 else print P?=$3. Include a class %ser&ain#ode with a static method Cec$I which accepts the string. The return tpe is a boolean !alue. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string. utput should print T(%3 or P?=$3 . (efer sample output for formatting speci"cations.
Sample Input 1: #T-*0)0)0 Sample Output 1: T(%3 Sample Input 2: #T1)*+1) Sample Output 2: P?=$3 import @a!a.util.$cannerF publicclass %ser&ain#ode G staticint !alidate7umber5$tring s16 G i" 5s1.matches55#T-6N0-OGL66 G return 1F
L else return -1F L publicstaticvoid main5$tringNO args6 G RR OO ?uto-generated method stub $canner in:ne& $canner5$stem.in6F $tring n1:in.ne
L L
+#.*la)in! &it Strin! < I
;i!en a string arra and non negati!e integer 5n6 appl the following rules. 1. ick nth character from each $tring element in the $tring arra and form a
new $tring. ). If nth character not a!ailable in a particular $tring in the arra consider C as the character. *. (eturn the newl formed string. Include a class %ser&ain#ode with a static method "ormStrin! which accepts the string and integer. The return tpe is the string formed based on rules. #reate a #lass &ain which would be used to accept the string and integer and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a an integer which denotes the si>e of the arra followed b the arra of strings and an integer 5n6. utput consists of a string . (efer sample output for formatting speci"cations. Sample Input 1: + ?H# X^Y 3P; &7 * Sample Output 1: #Y;C import java.util.Scanner; publicclass UserMainCode { publicstatic String stringHinder(String s1$8int n8int a) { String5u66er sb*new String5u66er(); for(int i*!;i9n;i::) { if(s1i$.length()?*a) sb.aend(s1i$.substring(a18a)); else &
Scanner in*new Scanner(S+stem.in); int n*0nteger. parseInt(in.ne,t-ine()); String s1$*new Stringn$; for(int i*!;i9n;i::) s1i$*in.ne,t-ine(); int a*0nteger. parseInt(in.ne,t-ine()); S+stem.out.rintln(UserMainCode.stringFinder (s18n8a));
in.close(); &
&
+%.,e!ular (5pression < 1
;i!en a string 5s6 appl the following rules. 1. $tring should be onl four characters long. ). Pirst character can be an alphabet or digit. *. $econd character must be uppercase '('. +. Third character must be a number between 0-. If all the conditions are satisifed then print T(%3 else print P?=$3. Include a class %ser&ain#ode with a static method validate which accepts the string. The return tpe is the boolean formed based on rules. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string. utput consists of T(%3 or P?=$3 . (efer sample output for formatting speci"cations. Sample Input 1: !(+u Sample Output 1: T(%3 Sample Input 2: !(au
;i!en the age of a person as string, !alidate the age based on the following rules. 1. alue should contain onl numbers. ). alue should be non-negati!e. *. alue should be in the range of )1 to +'. If all the conditions are satisifed then print T(%3 else print P?=$3. Include a class %ser&ain#ode with a static method Validate?!e which accepts the string. The return tpe is the boolean formed based on rules. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string. utput consists of T(%3 or P?=$3 . (efer sample output for formatting speci"cations.
Sample Input 1: )* Sample Output 1: T(%3 Sample Input 2: -*+ Sample Output 2: P?=$3 Sample Input +: *a Sample Output +: P?=$3 ?cHRT(%3 import @a!a.util.$cannerF publicclass %ser&ain#ode G static $tring !alidate7umber5$tring s16 G i" 5s1.matches5N0-OQ66 G int a:Integer. parseInt 5s16F i" 5a9:)1 MM a:)6 return!alidF L returnin!alidF L publicstaticvoid main5$tringNO args6 G RR OO ?uto-generated method stub $canner in:ne& $canner5$stem.in6F $tring n1:in.ne
L L
+-.,e!ular (5pression @ + 8*one Validator
;i!en a phone number as string, !alidate the same based on the following rules. 1. alue should contain onl numbers.
). alue should contain 10 digits. *. alue should not start with 00. If all the conditions are satisifed then print T(%3 else print P?=$3. Include a class %ser&ain#ode with a static method validate*one which accepts the string. The return tpe is the boolean formed based on rules. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string. utput consists of T(%3 or P?=$3 . (efer sample output for formatting speci"cations. Sample Input 1: //+*)1 Sample Output 1: T(%3 Sample Input 2: 001+)*+) Sample Output 2: P?=$3 import @a!a.util.$cannerF publicclass %ser&ain#ode G static $tring !alidate7umber5$tring s16 G i" 5s1.matches5N1-OG)LN0-OG/L66 G return!alidF
L returnin!alidF
L publicstaticvoid main5$tringNO args6 G RR OO ?uto-generated method stub $canner in:ne& $canner5$stem.in6F $tring n1:in.ne
L L
+0.Strin! Splitter
Write a program which would accept a string and a character as a delimiter. ?ppl the below rules 1. %sing the delimiter, split the string and store these elements in arra. ). (e!erse each element of the string and con!ert it into lowercase. Include a class %ser&ain#ode with a static method manipulateiteral which accepts the string and character. The return tpe is the string arra formed. #reate a #lass &ain which would be used to accept the string and characterand call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string and character. utput consists of a string arra. (efer sample output for formatting speci"cations. Sample Input 1: ???RbbaRcccREEE R Sample Output 1: aaa abb ccc ddd publicclass UserMainCode { publicstatic String$ comareashes(String s18char c) { String s*c:" "; StringEo3eni=er a*new StringEo3eni=er(s18s); int 3*!; String ans$*new Stringa.countEo3ens()$; while(a.hasMoreEo3ens()) { String b*a.ne,tEo3en();
Write a program to read a string and count the number of !owels present in it. Include a class %ser&ain#ode with a static method tellVo&elCount which accepts the string. The return tpe is the integer gi!ing out the count of !owels. 7ote8 The check is case-insensiti!e. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string. utput consists of integer. (efer sample output for formatting speci"cations. Sample Input 1: 7ew^ork Sample Output 1: ) Sample Input 2: 3lephant
Sample Output 2: * import @a!a.util.$cannerF publicclass%ser&ain#ode G publicstaticintcountowels5$tring s16 G $tring s:s1.to=ower#ase56F int c:0F "or5inti:0Fis.length56FiJJ6 G car k:s.char?t5i6F i" 5k::'a' UU k::'e' UU k::'i' UU k::'o' UU k::'u'6 JJcF L return cF L publicstaticvoid main5$tringNO args6 G $canner in:ne&$canner5$stem.in6F $tring s1:in.ne
in.close56F L L
41.*la)in! &it Strin! < II
Write a program to accept a string arra as input, con!ert all the elements into lowercase and sort the string arra. Eispla the sorted arra. Include a class %ser&ain#ode with a static method sort?rra) which accepts the string arra. The return tpe is the string arra formed based on re[uirement. #reate a #lass &ain which would be used to accept the string arra and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a an integer which denotes the si>e of the arra followed b the arra of strings, utput consists of a string arra. (efer sample output for formatting speci"cations. Sample Input 1:
Write a program to read a string and return true or false based on the below rule8 1. (eturn true if for e!er 'Q' in the string, there are same characters both side immediatel before and after the star, else return false.
Include a class %ser&ain#ode with a static method scanStarNei!bors which accepts the string. The return tpe is the boolean T(%3 or P?=$3 based on the rule. 7ote8 The check is case-insensiti!e. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format:
Write a program to read a string that contains a sentence and read a word. #heck the number of occurances of that word in the sentence. Include a class %ser&ain#ode with a static method count'ords which accepts the two strings. The return tpe is the integer gi!ing the count. 7ote8 The check is case-sensiti!e. #reate a #lass &ain which would be used to accept the two strings and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of two strings. utput consists of count indicating the number of occurances. (efer sample output for formatting speci"cations. Sample Input 1: 2ello world ]a!a is best programming language in the world world Sample Output 1: ) Sample Input 2: hello world World Sample Output 2: 0 import java.util.Scanner; import java.util.StringEo3eni=er;
Write Write a program to read two strings $1 M $), compute the number of times that $) appears in $1. Include a class %ser&ain#ode with a static method searcStrin! which accepts the two strings. The return tpe is the integer gi!ing the count. 7ote8 The check is case-insensiti!e. #reate a #lass &ain which would be used to accept the two strings and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of two strings. utput consists of count indicating the number of occurances. (efer (efer sample output for formatting speci"cations. Sample Input 1: #atcowcat cat Sample Output 1: )
Sample Input 2: #atcowcat catp Sample Output 2: 0 java.util.Scanner; import java.util.Scanner; import UserMainCode { publicclass UserMainCode publicclass searchString(String s18String n) staticint searchString(String staticint { String s4*s1.to-oerCase(); String s%*n.to-oerCase(); String s*s4.relace(s%8"" s*s4.relace(s%8""); ); l*!; int l*!; int (int i*!;i9s.length();i::) for( for int i*!;i9s.length();i::) (s.chart(i)**<< <<) ) if(s.chart(i)** if ::l; l; return l; return & main(String$ args) { main(String$ publicstaticvoid publicstaticvoi d TODO utogenerated method stub TODO utogenerated Scanner in*new in*new Scanner(S+stem. Scanner(S+stem.in); String n1*in.ne,t-ine(); String n*in.ne,t-ine(); S+stem.out.rintln(UserMainCode.searchString (n18n)); (n18n));
& &
43.Strin!s *rocessin!
Write Write a program to read a string that contains comma separated fruit names and also a number 7. ick the nth fruit and return it. If the total number of elements are less than the number speci"ed in 7, then return return the last element. Include a class %ser&ain#ode with a static method 6ndFruitName which accepts the the string and the number n. The return tpe is the string which has the fruit name. #reate a #lass &ain which would be used to accept the string and integer and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string and integer. integer. utput consists of a string. (efer (efer sample output for formatting speci"cations. Sample Input 1: ?pple,Hanana,range ) Sample Output 1: Hanana Sample Input 2: ?pple,Hanana,range + Sample Output 2: range import java.util.Scanner; import java.util.Scanner; java.util.StringEo3eni=er; import java.util.StringEo3eni=er; import UserMainCode { publicclass publiccl ass UserMainCode String 6indHruitName(String s18int s18int n) n) publicstatic String publicstatic { StringEo3eni=er st*new st*new StringEo3eni=er(s18 StringEo3eni=er(s18"8" "8"); ); String s*"" s*""; ; 3*st.countEo3ens(); int 3*st.countEo3ens(); int (int i*1;i9*3;i::) for( for int i*1;i9*3;i::) { (i**n) if(i**n) if { s*st.ne,tEo3en(); ; break; break & else { s*st.ne,tEo3en(); & & s; return s; return & main(String$ args) { main(String$ publicstaticvoi publicst aticvoid d Scanner in*new in*new Scanner(S+stem. Scanner(S+stem.in); String s1*in.ne,t-ine(); n*in.ne,t0nt(); int n*in.ne,t0nt(); int S+stem.out.rintln(UserMainCode.findFruitName(s18n)); in.close();
&
&
4-.*roper Case
Write a program to read a string and con!ert the intial letter of each word to uppercase. Include a class %ser&ain#ode with a static method can!eCase which accepts the string. The return tpe is the modi"ed string. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string. utput consists of a string. (efer sample output for formatting speci"cations. Sample Input 1: This is cogni>ant academ Sample Output 1: This Is #ogni>ant ?cadem publicclass %ser&ain#ode G publicstatic $tring print#apitali>ed5$tring s16 G $tringHu4er s:ne& $tringHu4er56F $tringTokeni>er t:ne& $tringTokeni>er5s1, 6F &ile5t.has&oreTokens566G $tring s):t.ne
L
L publicstaticvoid main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F $tring s1:in.ne
40.en!t o" same &ord
Write a program to read a string containing multiple words "nd the "rst and last words, if the are same, return the length and if not return the sum of
length of the two words. Include a class %ser&ain#ode with a static method compareast'ords which accepts the string. The return tpe is the length as per problem. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of a string. utput consists of a integer. (efer sample output for formatting speci"cations. Sample Input 1: This is #ogni>ant ?cadem Sample Output 1: 11 Sample Input 2: 2ello World 2ello Sample Output 2: import java.util.Scanner; publicclass UserMainCode { staticint validateNumber(String s1) { int a*s1.inde,I6(" "); int b*s1.last0nde,I6(" "); String s*s1.substring(!8a); String s4*s1.substring(b:1); if(s.eGuals(s4)) return s.length(); return (s.length():s4.length()); & main(String$ args) { publicstaticvoid TODO utogenerated method stub Scanner in*new Scanner(S+stem.in); String n1*in.ne,t-ine(); S+stem.out.rintln(UserMainCode.validateNumber (n1));
& &
#1.Find i!its
Por a gi!en double number with atleast one decimal !alue, Write a program to compute the number of digits before and after the decimal point in the following format nofEigitsHeforeEecimal8nofEigits?fterEecimal. 7ote8 Ignore >eroes at the end of the decimal 53ero is the onl digit after decimal. (efer 3
Input consists of a double. utput consists of string. (efer sample output for formatting speci"cations. Sample Input 1: /+*.)1 Sample Output 1: *8) Sample Input 2: )0.1*0 Sample Output 2: )8) Sample Input +: )0.1*0 Sample Output +: )8) import java.util.Scanner; import java.util.StringEo3eni=er; publicclass UserMainCode { static String validateNumber(double d) { int n1*!8n4; String s*String.valueOf (d); StringEo3eni=er t*new StringEo3eni=er(s8"."); String s1*t.ne,tEo3en();
Write a program to read a string and return the length of the largest chunk in the string. ? chunk is a repetition of same character ) or more number of times. If the gi!en string doest not contain an repeated chunk of characters return -1. Include a class %ser&ain#ode with a static method !etar!estSpan which accepts the string. The return tpe is the integer. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of a string. utput consists of integer. (efer sample output for formatting speci"cations. Sample Input 1: This place is soooo good Sample Output 1: + importjava.util.Scanner;
;i!en a string 5s6 appl the following rules. I6?t least / characters must be present II6?t least one capital letter must be present III6?t least one small letter must be present
I!6?t least one special smbol must be present 6?t least one numeric !alue must be present If the condition is satisifed then print !alid else print in!alid. Include a class %ser&ain#ode with a static method pass&ordValidation which accepts the string. The return tpe is the string. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of a string. utput consists of string 5!alid R in!alid6 . (efer sample output for formatting speci"cations. Sample Input 1: TechnologC1)1* Sample Output 1: !alid import java.util.Scanner; publicclassUserMainCode { staticint assord/alidation(String s) { if(s.length()?*PAAs.matches(".2>$.2")AAs.matches(".2a =$.2")AAs.matches(".2!#$.2")AAs.matches(".2K!#>a=$.2")) return 1; return 1; & main(String$ args) publicstaticvoid { Scanner in*new Scanner(S+stem.in); String s*in.ne,t-ine(); int b*UserMainCode. passordValidation(s); if(b**1) S+stem.out.rintln("valid"); else S+stem.out.rintln("invalid"); & &
%-.Strin! processin! @ on! ; Sort ; on!
btain two strings $1,$) from user as input. ^our program should form a string of ZlongJshortJlongS, with the shorter string inside of the longer $tring. Include a class %ser&ain#ode with a static method !etCombo which accepts two string !ariables. The return tpe is the string. #reate a #lass &ain which would be used to accept two Input strings and call the static method present in %ser&ain#ode.
Input and Output Format: Input consists of two strings with mae of 100 characters. utput consists of an string.
;i!en a date of birth 5ddR&&R6 of a person in string, compute his age as of 01R01R)01. If his age is greater than 1/, then println eligible else println not-eligible. Include a class %ser&ain#ode with a static method get?ge which accepts the string !alue. The return tpe is the string. #reate a #lass &ain which would be used to accept the two string !alues and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of two string. utput consists of a string. (efer sample output for formatting speci"cations. Sample Input 1:
1R11R11 Sample Output 1: eligible import @a!a.te
L L returnnot eligibleF L public static void main5$tringNO args6 G
$canner in:ne& $canner5$stem.in6F $tring s1:in.ne
$tring s):01R01R)01F $stem.out .println5%ser&ain#ode.getvalues5s1,s)66F L L
2. Strin!s @ Uni7ue A (5istin! Caracters btain two strings from user as input. ^our program should modif the "rst string such that all the characters are replaced b plus sign 5J6 ee of 100 characters. utput consists of a single string. (efer sample output for formatting speci"cations. Sample Input 1: abc<> a
L public static void main5$tring NOargs6G
$canner sc:ne& $canner5$stem.in6F $tring n:sc.ne
+. on!est 'ord Write a rogram which "nds the longest word from a sentence. ^our program should read a sentence as input from user and return the longest word. In case there are two words of mae of 100 characters. utput consists of a single string. (efer sample output for formatting speci"cations. Sample Input 1: Welcome to the world of rogramming Sample Output 1: rogramming Sample Input 2: ?H# E3P Sample Output 2: ?H# import @a!a.util.QF public class %ser&ain#ode G public static $tring lengthiest$tring5$tring s16 G int ma<:0F $tring s):ne& $tring56F $tringTokeni>er t: ne& $tringTokeni>er5s1, 6F &ile5t.has&oreTokens566 G $tring s*:t.ne
$stem.out .println5lengthiesttring5s166F L L
4. Strin! Occurences btain two strings from user as input. ^our program should count the number of occurences of second word of second sentence in the "rst sentence. (eturn the count as output. 7ote - #onsider case. Include a class %ser&ain#ode with a static method countNoO"'ords which accepts two string !ariables. The return tpe is the modi"ed string. #reate a #lass &ain which would be used to accept two Input strings and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of two strings with mae of 100 characters. utput consists of a single string. (efer sample output for formatting speci"cations. Sample Input 1: abc bcd abc bcd abc abc a! abc Sample Output 1: + Sample Input 2: ?H# <> ??? w abc Sample Output 2: 0 import @a!a.util.$cannerF import @a!a.util.$tringTokeni>erF public class %ser&ain#ode G public static void get!alues5$tring s1, $tring s)6 G int count:0F $tringTokeni>er st:ne& $tringTokeni>er5s), 6F $tring s*:st.neer st1:ne& $tringTokeni>er5s1, 6F &ile5st1.has&oreTokens566 G $tring s:st1.ne
%ser&ain#ode.getvalues5s1,s)6F L L
Concatenate Caracters
;i!en an arra of $trings, write a program to take the last character of each string and make a new $tring b concatenating it. Include a class UserMainCode with a static method BconcatCaracter that accepts a $tring arra as input and returns the new $tring. #reate a class Main which would get the $tring arra as input and call the static method concatCaracterpresent in the %ser&ain#ode. Input and Output Format: The "rst line of the input consists of an integer n that corresponds to the number of strings in the input string arra. The ne
12.?na!ram
Write a program to check whether the two gi!en strings are anagrams. 7ote8 (earranging the letters of a word or phrase to produce a new word or phrase, using all the original letters eant technologies Sample Output +: 7ot ?nagrams import @a!a.util.?rrasF import @a!a.util.$cannerF public class %ser&ain#ode G static int get?nagram5$tring str1,$tring str)6 G car NOa1:str1.to=ower#ase56.replace?ll5\\s,6.to#har?rra56F car NOa):str).to=ower#ase56.replace?ll5\\s,6.to#har?rra56F
?rras.sort 5a16F ?rras.sort 5a)6F i" 5?rras.equals 5a1,a)66 return 1F return -1F L public static void main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F $tring str1:in.ne
1+.Calculate Meter ,eadin!
;i!en ) strings corresponding to the pre!ious meter reading and the current meter reading, write a program to calculate electricit bill. The input string is in the format ?????XXXXX. ????? is the meter code and XXXXX is the meter reading. P(&%=?8 5XXXXX-XXXXX6Q+ 2int8 if ????? of input1 and input) are e[ual then separate the XXXXX from string and con!ert to integer. ?ssume that ????? of the ) input strings will alwas be e[ual. Include a class UserMainCode with a static method BcalculateMeter,eadin! that accepts ) $tring arguments and returns an integer that corresponds to the electricit bill. The 1st argument corresponds to the pre!ious meter reading and the )nd arguement corresponds to the current meter reading. #reate a class Main which would get ) $trings as input and call the static method calculateMeter,eadin! present in the %ser&ain#ode. Input and Output Format: Input consists of ) strings. The "rst input corresponds to the pre!ious meter reading and the second input corresponds to the current meter reading.
utput consists of an integer that corresponds to the electricit bill. Sample Input: #$3#31)*0 #$3#31)+00
Sample Output: +0 import @a!a.util.$cannerF public class %ser&ain#ode G static int calculate3lectricitHill5$tring str1,$tring str)6 G int e1:Integer. parseInt 5str1.substring566F int e):Integer. parseInt 5str).substring566F int total:5e)-e16Q+F return totalF
L public static void main5$tring argsNO6
G $tring s1,s)F int nF $canner in:ne& $canner5$stem.in6F s1:in.ne
1%.Vo&els
;i!en a $tring input, write a program to "nd the word which has the the ma
Sample Output : our import @a!a.util.$cannerF import @a!a.util.$tringTokeni>erF public class %ser&ain#ode G public static $tring lengthiest$tring5$tring s16 G int ma<:0F $tring s):ne& $tring56F $tringTokeni>er t:ne& $tringTokeni>er5s1, 6F &ile5t.has&oreTokens566 G $tring s:t.ne
2/.ar!est Span
Write a program to read an arra and "nd the si>e of largest span in the gi!en arra span is the number of elements between two repeated numbers including both numbers. ?n arra with single element has a span of 1. . Include a class %ser&ain#ode with a static method !etMa5Span which accepts a single integer arra. The return tpe 5integer6 should be the si>e of largest span. #reate a #lass &ain which would be used to accept Input arra and call the static method present in %ser&ain#ode. Input and Output Format:
Input consists of nJ1 integers. The "rst integer corresponds to n, the number of elements in the arra. The ne
L public static void main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F int n:in.ne
21.Ma5 Scorer
Write a program that performs the following actions8 1. (ead n strings as input and stores them as an arralist. The string consists of student information like name and obtained marks of three sub@ects. 3g8 name-mark1-mark)-mark* Nsuresh-0-+-1)O The mark would range between 0 100 5inclusi!e6. ). Write a function i!estScorer which accepts these the arralist and returns the name of the student who has scored the ma< marks. ?ssume the result will ha!e onl one student with ma< mark. Include a class %ser&ain#ode with the static method i!estScorer which accepts the arralist and returns the name 5string6 of ma< scorer. #reate a #lass &ain which would be used to read n strings into arralist and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of 1 integer and n strings. The "rst integer denotes the si>e of the arralist, the neerF public class %ser&ain#ode G static $tring highest$corer5$tring arNO6 G $tring name:F int score:0F "or5int i:0Fiar.lengthFiJJ6
G $tringTokeni>er st: ne& $tringTokeni>er5arNiO,-6F $tring tname:st.ne
22.Ma5 Vo&els
Write a rogram which fetches the word with mae of 100 characters. utput consists of a single string. (efer sample output for formatting speci"cations. Sample Input 1: ?ppreciation is the best wa to moti!ate Sample Output 1: ?ppreciation import @a!a.util.$cannerF import @a!a.util.$tringTokeni>erF public class %ser&ain#ode G
public static $tring lengthiest$tring5$tring s16 G int ma<:0F $tring s):ne& $tring56F $tringTokeni>er t:ne& $tringTokeni>er5s1, 6F &ile5t.has&oreTokens566 G $tring s:t.ne
24.?dDacent S&aps
Write a rogram that accepts a string as a parameter and returns the string with each pair of ad@acent letters re!ersed. If the string has an odd number of letters, the last letter is unchanged. Include a class %ser&ain#ode with a static method s&ap*airs which accepts a string. The return tpe is string which is re!ersed pair of letters. #reate a #lass &ain which would be used to accept two Input strings and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of a string with mae of 100 characters. utput consists of a single string. (efer sample output for formatting speci"cations. Sample Input 1: forget Sample Output 1: ofgrte
Sample Input 2: 7ew ^ork
Sample Output 2: e7 wo^kr import @a!a.util.$cannerF public class %ser&ain#ode G public static $tring swap#haracter5$tring s16 G $tringHu4er sb:ne& $tringHu4er56F "or5int i:0Fis1.length56Fi:iJ)6 G car c,dF i" 5iK:s1.length56-16 G c:s1.char?t5i6F d:s1.char?t5iJ16F sb.append5d6F sb.append5c6F L else G c:s1.char?t5i6F sb.append5c6F L
L return sb.to$tring56F L public static void main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F $tring s1:in.ne
2%.*ass&ord
;i!en a $tring , write a program to "nd whether it is a !alid password or not. alidation (ule8 ?tleast / characters ?tleast 1 number51,),*...6 ?tleast 1 special character5A,B,D...6
?tleast 1 alphabet5a,H...6 Include a class UserMainCode with a static method Zvalidate*ass&ord S that accepts a $tring argument and returns a boolean !alue. The method returns true if the password is acceptable. 3lse the method returns false. #reate a class Main which would get a $tring as input and call the static method validate*ass&ord present in the %ser&ain#ode. Input and Output Format: Input consists of a $tring. utput consists of a $tring that is either ZalidS or ZIn!alidS. Sample Input 1: ctsA1010 Sample Output 1: alid Sample Input 2: punitha* Sample Output 2: In!alid import @a!a.util.$cannerF public class %ser&ain#ode G static int passwordalidation5$tring s6 G i" 5s.length569:/MMs.matches5.QNa->?-YO.Q6MMs.matches5.QN0O.Q6MMs.matches5.QN0-?-Ya->O.Q66 return 1F return -1F L public static void main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F $tring s:in.ne
+/.?na!rams
Write a program to read two strings and checks if one is an anagram of the
other. ?n anagram is a word or a phrase that can be created b rearranging the letters of another gi!en word or phrase. We ignore white spaces and letter case. ?ll letters of 'Eesperation' can be rearranged to the phrase '? (ope 3nds It'. Include a class %ser&ain#ode with a static method cec$?na!ram which accepts the two strings. The return tpe is boolean which is T(%3 R P?=$3. #reate a #lass &ain which would be used to accept the two strings and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of two strings. utput consists of T(%3 R P?=$3. (efer sample output for formatting speci"cations. Sample Input 1: tea eat Sample Output 1: T(%3 Sample Input 2: Eesperation ? (ope 3nds It Sample Output 2: T(%3 import @a!a.util.?rrasF import @a!a.util.$cannerF public class %ser&ain#ode G static int get?nagram5$tring str1,$tring str)6 G car NOa1:str1.to=ower#ase56.replace?ll5\\s,6.to#har?rra56F car NOa):str).to=ower#ase56.replace?ll5\\s,6.to#har?rra56F ?rras.sort 5a16F ?rras.sort 5a)6F i" 5?rras.equals 5a1,a)66 return 1F return -1F L public static void main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F $tring str1:in.ne
L L
+2.'ord Count
;i!en a string arra 5s6 with each element in the arra containing alphabets or digits. Write a program to add all the digits in e!er string and return the sum as an integer. If two digits appear simultaneousl do not consider it as one number. 3<- Por '2derabad )1' consider ) and 1 as two digits instead of )1 as a number. Include a class %ser&ain#ode with a static method sumO"i!its which accepts the string arra. The return tpe is the integer formed based on rules. #reate a #lass &ain which would be used to accept the string and integer and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of a an integer indicating the number of elements in the string arra. utput consists of a integer . (efer sample output for formatting speci"cations. Sample Input 1: ???1 H)H +### ? ?H#E3 Sample Output 1: 1) Sample Input 2: * 1) #)* #() Sample Output 2: 1 import @a!a.util.$cannerF public class %ser&ain#ode G static int sumfEigits5$tring strNO6 G int sum:0,iF
G $canner in:ne& $canner5$stem.in6F int n1:Integer. parseInt 5in.ne
++.*re65 Finder
;i!en a string arra 5s6 with each element in the arra containing 0s and 1s. Write a program to get the number of strings in the arra where one $tring is getting as pre"
Sample Input 1: + 0 1 11 110 Sample Output 1: * import Dava.util.ScannerE public class *re65Finder public static int 6nd*re658Strin! sGH int count/E "or8int i/EiJs.len!tEi;; int c1E "or8int D/EDJs.len!tED;; i"8sGDH.matces8KLK;sGiH;KG1/H1K c;;E i"8ccount countcE return countE public static void main8Strin!GH ar!s Scanner inne& Scanner8S)stem.inE int nInte!er.parseInt8in.ne5tine8E Strin!GH ane& Strin!GnHE "or8int i/EiJnEi;; aGiHin.ne5tine8E S)stem.out.println8*re65Finder.6nd*re658aE
+4.Commons
;i!en two arras of strings,return the count of strings which is common in both arras. Euplicate entries are counted onl once. Include a class %ser&ain#ode with a static method countCommonStrin!s which accepts the string arras. The return tpe is the integer formed based on rules. #reate a #lass &ain which would be used to accept the string arras and integer and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of a an integer indicating the number of elements in the string
arra followed b the arra. utput consists of a integer . (efer sample output for formatting speci"cations. Sample Input 1: * a c e * b d e Sample Output 1: 1 Sample Input 2: ba ba black sheep wool ba ba ha!e an wool Sample Output 2: ) import java.util.QashSet; import java.util.Scanner; public class UserMainCode { public static int countCommon(String ss1$8String ss4$) { QashSet9String? h*new QashSet9String?(); for(int i*!;i9ss1.length;i::) h.add(ss1i$); String s1$*new Stringh.si=e()$; h.torra+(s1); QashSet9String? h1*new QashSet9String?(); for(int i*!;i9ss4.length;i::) h1.add(ss4i$); String s4$*new Stringh.si=e()$; h.torra+(s4); int count*!;
+%.(
Write a program to read a string and !alidate the gi!en email-id as input. alidation (ules8 1. 3nsure that there are atleast characters between 'A' and '.' ). There should be onl one '.' and one 'A' smbol. *. The '.' should be after the 'A' smbol. +. There must be atleast three characters before 'A'. . The string after '.' should onl be 'com' Include a class %ser&ain#ode with a static method Validate(mail which accepts the string. The return tpe is T(%3 R P?=$3 as per problem. #reate a #lass &ain which would be used to accept the string and call the static method present in %ser&ain#ode. Input and Output Format: Input consists of a string. utput consists of T(%3 R P?=$3. (efer sample output for formatting speci"cations. Sample Input 1: testAgmail.com Sample Output 1: T(%3 Sample Input 2:
academA<>.com Sample Output 2: P?=$3 import @a!a.util.$cannerF public class %ser&ain#ode G static boolean !alidate3mail5$tring str6 G return str.matches5Na->?-Y0-OG*LANa->?-YOGL\\.com6F L public static void main5$tringNO args6 G $canner in:ne& $canner5$stem.in6F $tring s:in.ne
4/.ISN Validation
Write a program to read a string and !alidate the gi!en I$H7 as input. alidation (ules8 1. ?n I$H7 5International $tandard Hook 7umber6 is a ten digit code which uni[uel identi"es a book. ). To !erif an I$H7 ou calculate 10 times the "rst digit, plus times the second digit, plus / times the third ..all the wa until ou add 1 times the last digit. If the "nal number lea!es no remainder when di!ided b 11 the code is a !alid I$H7. 3