import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws FileNotFoundException, IOException {
File file = new File(args[0]);
BufferedReader in = new BufferedReader(new FileReader(file));
StringBuffer sb=new StringBuffer();
String line;
while ((line = in.readLine()) != null) {
int counter=0;
int n=0;
for(int i=0;i<line.length();i++){
char c=line.charAt(i);
if(c>='a'&&c<='z'){
counter++;
n++;
}else if(c>='A'&&c<='Z'){
n++;
}
}
sb.append(String.format("lowercase: %.2f uppercase: %.2f", (counter*100.0)/n,((n-counter)*100.0)/n)).append('\n');
}
System.out.print(sb);
}
}
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws FileNotFoundException, IOException {
File file = new File(args[0]);
BufferedReader in = new BufferedReader(new FileReader(file));
StringBuffer sb=new StringBuffer();
String line;
while ((line = in.readLine()) != null) {
int counter=0;
int n=0;
for(int i=0;i<line.length();i++){
char c=line.charAt(i);
if(c>='a'&&c<='z'){
counter++;
n++;
}else if(c>='A'&&c<='Z'){
n++;
}
}
sb.append(String.format("lowercase: %.2f uppercase: %.2f", (counter*100.0)/n,((n-counter)*100.0)/n)).append('\n');
}
System.out.print(sb);
}
}
No comments:
Post a Comment