Search This Blog

UI/UX Design | Web Development | Mobile Application Development

Whether you need UI/ UX design, web development services, or mobile app development services, Qaabil Digitals will be more than happy to help you. We work with top software developers, designers, and project managers. We tailor our services to suit your exact needs. We closely look at your company, listen to your story, and bring about the best ideas and solutions that can help you drive solid results. We don’t just produce work that works. We produce work that matters. Get a quote now Or Talk to us

Saturday, 5 November 2011

Java program to create an ARRAY of 5 STRINGS. The program finds and displays the total number of vowels (both uppercase and lowercase) in all five strings by (Adler Lawn Service, LLC)


import java.util.*;
class vowels
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
String n="",n1,n2,n3,n4,n5;
char c;
int r=1;

System.out.print ("\n\t Enter first name of first person = ");
n1 = in.nextLine();
System.out.print ("\n\t Enter first name of second person = ");
n2 = in.nextLine();
System.out.print ("\n\t Enter first name of third person = ");
n3 = in.nextLine();
System.out.print ("\n\t Enter first name of fourth person = ");
n4 = in.nextLine();
System.out.print ("\n\t Enter first name of fifth person = ");
n5 = in.nextLine();

while (r<6)
{
if (r==1)
{
n=n1;
System.out.print ("\n\n\t Vowels in first person's name = ");
}
else if (r==2)
{
n=n2;
System.out.print ("\n\n\t Vowels in second person's name = ");
}
else if (r==3)
{
n=n3;
System.out.print ("\n\n\t Vowels in third person's name = ");
}
else if (r==4)
{
n=n4;
System.out.print ("\n\n\t Vowels in fourth person's name = ");
}
else if (r==5)
{
n=n5;
System.out.print ("\n\n\t Vowels in fifth person's name = ");
}
else
System.out.println ();

for (int i=0;i<n.length();++i)
{
c=n.charAt(i);
switch (c)
{
case 'A':
case 'a':
System.out.print (" "+c);
break;
case 'E':
case 'e':
System.out.print (" "+c);
break;
case 'I':
case 'i':
System.out.print (" "+c);
break;
case 'O':
case 'o':
System.out.print (" "+c);
break;
case 'U':
case 'u':
System.out.print (" "+c);
break;
default:
System.out.print ("");
}
}

++r;
}

}
}

No comments:

Post a Comment

Share