السلام عليكم
انا قد كتبت سوال وهو المطلوب اني احل بكلاسين
وسويته بكلاسين
بس الغلط هنا المسافه ما يحسبه
اش الغلط
هذا المين :
// TODO code application logic here
String v;
Scanner s=new Scanner(System.in);
System.out.println("enter the string");
v=s.next();
Vowels obj=new Vowels(v);
obj.setCounters();
System.out.println("the a vowel found "+obj.getacount());
System.out.println("the o vowel found "+obj.getocount());
System.out.println("the e vowel found "+obj.getecount());
System.out.println("the i vowel found "+obj.geticount());
System.out.println("the u vowel found "+obj.getucount());
System.out.println("the spaces="+obj.getspaces());
}
}
public static void main(String[] args) {وهذا كلاس
package countvowels;
import java.util.*;
/**
*
* @author انس
*/
public class Vowels {
private String str;
private int acount;
private int ocount;
private int ecount;
private int icount;
private int ucount;
private int spaces;
public Vowels(String s){
acount=0;
ocount=0;
ecount=0;
icount=0;
ucount=0;
spaces=0;
str=s;
}
public void setCounters(){
for(int i=0; i<str.length(); i++)
{
if(str.charAt(i)=='a'||str.charAt(i)=='A')
acount++;
else if(str.charAt(i)=='o'||str.charAt(i)=='O')
ocount++;
else if(str.charAt(i)=='e'||str.charAt(i)=='E')
ecount++;
else if(str.charAt(i)=='i'||str.charAt(i)=='I')
icount++;
else if(str.charAt(i)=='u'||str.charAt(i)=='U')
ucount++;
elseif(str.charAt(i)==' ')
spaces++;
}
}
public int getacount(){
return acount;الله يسعدكم