Java
Programming and Technical
Programming
Program
import java.io.BufferedReader;
//import java.io.FileNotFoundException;
import java.io.FileReader;
public class Calculatefrompara {
private static BufferedReader bin;
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
FileReader fin=new FileReader("test.txt");
bin = new BufferedReader(fin);
int Alphabets=0,digits=0,splchars=0,lowercase=0,uppercase=0;
String line=bin.readLine();
int i;
//char c1;
while(line!=null)
{
for( i=0;i=97 && j<=122)|| (j>=65 && j<=90))
{
Alphabets++;
}
else
if(j>=97 && j<=122)
{
lowercase++;
}
else
if(j>=65 && j<=90)
{
uppercase++;
}
else
if(j>=48 && j<=57)
{
digits++;
}
else
{
splchars++;
}
}
line=bin.readLine();
}
System.out.println("alphabets:"+Alphabets);
System.out.println("lowercase:"+lowercase);
System.out.println("uppercase:"+uppercase);
System.out.println("digits:"+digits);
System.out.println("splchrs:"+splchars);
}
}
Read Solution (Total 2)
-
- why don't you try using patterns [a-z][A-Z][0-9] it will be much easier that way
- 8 years agoHelpfull: Yes(1) No(0)
- hi frends i am getting 0 no of uppercase .lowercase and digits , plz tell me where is the mistake?
- 9 years agoHelpfull: Yes(0) No(1)
Java Other Question