Professional Documents
Culture Documents
Scanner;
class Timer {
public static Scanner sc=new Scanner(System.in);
char[] a = new char[] {'P','h','i','l','l','i','p',' ','a','n','d',' ','A','l','e','x',' ','p','l','a','y','e','d','
','i','n',' ','t','h','e',' ','s','n','o','w',' ','a','l','l',' ','d','a','y',' ','l','o','n','g'};
char[] b = new char[] {'K','a','t','e',' ','a','n','d',' ','P','a','u','l',' ','w','e','n','t','
','s','h','o','p','p','i','n','g',' ','a','n','d',' ','b','r','o','u','g','h','t',' ','b','r','e','a','d',',',' ','c','h','e','e','s','e','
','a','n','d',' ','m','i','l','k'};
char[] c = new char[] {'T','h','e',' ','b','o','y',' ','r','a','n',' ','a','l','l',' ','t','h','e',' ','w','a','y','
','h','o','m','e',' ','i','n',' ','t','h','e',' ','r','a','i','n'};
char[] d = new char[] {'T','h','e',' ','s','c','h','o','o','l',' ','f','o','o','t','b','a','l','l',' ','t','e','a','m','
','e','v','e','n','t','u','a','l','l','y',' ','w','o','n',' ','t','h','e',' ','g','a','m','e',' ','b','y',' ','t','h','r','e','e','
','g','o','a','l','s'};
char[] e = new char[] {'C','a','r','l',' ','w','o','n',' ','t','h','e',' ','s','p','e','l','l','i','n','g',' ','b','e','e','
','a','n','d',' ','w','o','n',' ','t','h','e',' ','t','r','o','p','h','y'};
}
System.out.println("The number if errors is "+errors(x,ch));
}
public static boolean isLength(char[] x,char[] ch) {
if(ch.length<x.length) {
System.out.println("Sentence is too short");
return false;
}
else if(ch.length>x.length) {
System.out.println("Sentence is too long");
return false;
}
else
return true;
}
public static int errors(char[] x, char[] ch) {
int count=0;
for(int i=0;i<ch.length;i++) {
if(ch[i]==x[i]) {}
else if(ch[i]!=x[i]) {
count+=1;
theError(ch,i);
}
}
return count;
}