USE JAVA FOR:
1) Count the letters in string.
2) Print random number.
Answers
Answered by
3
Solution:
This is written in Java.
1.
public class Program {
public static void main(String[] args) {
String s="purveshKolhe0001";
int count=0;
for(int i=0;i<s.length();i++){
char x=s.toLowerCase().charAt(i);
if (x>='a' && x<='z')
count++;
}
System.out.println("Number of letters\nin \""+s+"\" is: "+count);
}
}
2.
public class Program {
public static void main(String[] args) {
System.out.println(Math.random());
}
}
Note:
- For the first question, I have counted only the letters (a to z).
- For the second question, use Math.random() function. It generates random decimal number between 0 and 1.
Output:
1.
Number of letters
in "purveshKolhe0001" is 12
2.
Any random value.
Answered by
1
Answer:
Explanation:
) Count the letters in string.
2) Print
Can u intro urself i wanted to know u
plzzzz
Similar questions