Here is the code
import java.util.Scanner;
public class Test
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the String : ");
String x=sc.nextLine();
int n=x.length();
int countVowels=0;
int special=0;
System.out.print("The locations of vowels are: ");
for(int i=0;i<n;i++)
{
if(x.charAt(i)=='a'||x.charAt(i)=='e'||x.charAt(i)=='i'||x.charAt(i)=='o'||x.charAt(i)=='u'||x.charAt(i)=='A'||x.charAt(i)=='E'||x.charAt(i)=='I'||x.charAt(i)=='O'||x.charAt(i)=='U')
{
System.out.print(i+" ");
countVowels++;
}
}
System.out.println("\nThe number of vowels is: "+countVowels);
for(int i=0;i<n;i++)
{
if((x.charAt(i)>='a'&&x.charAt(i)<='z')||(x.charAt(i)>='A'&&x.charAt(i)<='Z')||(x.charAt(i)=='
'))
{
}
else
{
special++;
}
}
System.out.println("The number of special characters and numbers:
"+special);
}
}
Output
C++ program by netBeans java language Exercise #2: Write a java program that prompts the user...
Exercise #3: write a Java program that prompts the user to enter a sentence. The program has to find the print: a. the position of vowels in the sentence. b. the number of vowels in the sentence (A, a, U, u, E, e, O, o, I, i) c. the number of characters as numbers or special characters (other than English letters a.z, A..Z). Hint: remember to ignore the spaces. Sample input-output: Enter the sentnse: UAEU is the university of the...
Java: Assume letters A E O U I as the vowels. Write a program that prompts the user to enter a string and displays the number of vowels and consonants in the string. The same vowels or consonants are counted only once. Use sets in the code.
In Java, write a program that prompts the user to input a sequence of characters and outputs the number of vowels. You will need to write a method to return a value called isAVowel which will return true if a given character is a vowel and returns false if the character is not a vowel. A second method, called isAConstant, should return true if a given character is a constant and return false if the character is not a constant....
Char type: Edit the provided starter-code char_type.py so it takes the user to enter some text, then display the number of vowels, consonants,digits, and special characters in the text. In english the vowels are the letters "a" , "e" , "i", "o", "u", "y". All other letters are consonants. The digits are "0"-"9". The special characters are those that are not letters or digits. The program should countthe number of each type of character in the text user enters, then...
Use C++ language, keep it simple Exercise #2: Strings' operations Write a C++ program that prompts the user to enter a sentence, the program then does the following: 1. Prints the total characters in the sentence. 2. Prints the word count of the sentence, assuming only one space between each tow words. 3. Prints total vowel (a, e, i, o, u) in the sentence. 4. Prints the vowel frequency as shown in the sample below. 5. Prints the sentence in...
Vowel or Consonant?Write a program for Programming Exercise 4.10 on p.151 in the textbook. Testing: Run the program for two vowels, two consonants, and two invalid characters. Assume letters A/a , E/e , I/i , O/o , U/u as the vowels. Write a program that prompts the user to enter a letter and check whether the letter is a vowel or constant.
Write a C program that will produce the EXACT output shown below. Write a program to find out the number of words, spaces, vowels, consonants, along with special characters in a sentence. Take the data below as an example. Your C program should take the data in the arrays and produce the output below, neatly formatted as shown Enter a sentence: My cat’s name is Bella. You sentence includes: Number of words: 5 Number of spaces: 4 ...
String variables/Selection & loop Write a complete Java program which prompts the user for a sentence on one line where each word is separated by one space, reads the line into one String variable using nextline(), converts the string into Ubbi dubbi and displays the translated sentence. Ubbi dubbi works by adding ub before each vowel sound in a syllable. For example, hello becomes hubellubo. The word speak has the vowel sound ea, so in Ubbi dubbi it becomes spubeak....
Please help me with this program in Java: Write a Java program that prompts the user to enter a password that matches a specific pattern. Your program must approve the user's entry.. Here is the pattern, in this order: 1 or more upper case letters two lower case letters 1 or 2 digits zero or 1 upper case letters any two of this group @#$%^&
Write a C program that prompts the user for an input string with all lowercase letters. Your program should then sort the characters in the string and print the sorted string. Assume that the string contains no spaces and has at most 30 lowercase characters. Your program should loop continually until the user enters “q” to quit.