Method named isallvowels that returns

Assignment Help JAVA Programming
Reference no: EM13161168

Write a method named isAllVowels that returns whether a String consists entirely of vowels (a, e, i, o, or u, case-insensitively). If every character of the String is a vowel, your method should return true. If any character of the String is a non-vowel, your method should return false. Your method should return true if passed the empty string, since it does not contain any non-vowel characters.

For example, here are some calls to your method and their expected results:

CallValue Returned
isAllVowels("eIEiO") true
isAllVowels("oink") false

Code:

public static boolean isAllVowels(String s)
{
boolean flag = false;
for (int i = 0; i < s.length(); i++)
{
switch(Character.toLowerCase(s.charAt(i)))
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
//case " " :
flag = true;
break;
default:
flag = false;
}
}

return flag;
}


public static void main (String args[])
{

System.out.println(isAllVowels("eIEiO"));
System.out.println(isAllVowels("oink"));
}

Reference no: EM13161168

Questions Cloud

State what is the frequency of light : A red laser pointer emits light with a wavelength of 660. What is the frequency of this light? 2.What is the energy of one of these photons?
How can predator populations function as agents : How can predator populations function as agents of natural selection in prey populations? How can prey populations function as agents of natural selection in predator populations?
The arm assembly language routine : For the ARM assembly language routine below, what function does it perform for the calling program?
Method called wordlengths that accepts a scanner : Write a method called wordLengths that accepts a Scanner representing an input file as its argument. Your method should read from the given file.
Method named isallvowels that returns : Write a method named isAllVowels that returns whether a String consists entirely of vowels (a, e, i, o, or u, case-insensitively). If every character of the String is a vowel, your method should return true. If any character of the String is a non-vo..
Multidimensional arrays : multidimensional arrays to life, let's consider a specific example: How can you visualize a 4-dimensional array? How can you give meaning to each dimension this array has? What kind of application would such an array be useful for?
What is the energy required to move a mole of urea out : What is the energy required to move a mole of urea out of the kidney cells and into the urine?
What is the minimal total weight of cylinders : A scuba diver uses a special equipment for diving. He has a cylinder with two containers: one with oxygen and the other with nitrogen. Depending on the time he wants to stay under water and the depth of diving the scuba diver needs various amount of ..
Create a file, shared.txt : When your program starts, it shall do the following:1. Create a file, SHARED.txt, in the current directory (cwd). 2. Write it's pid (Process ID) followed by a Carriage Return and Newline in the file.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Bilinear and nearest neighbour algorithm in java

How to do bilinear and nearest neighbour algorithm in java. Show how to eliminate change in pixel aspect ratio in java.

  Develop java package comprising of class using encapsulation

Develop the Java package comprising of Class and Student with the given requirements. Encapsulation, Method to print student details alone.

  Java project

Prompt the user for an int between lower and upper boundary.

  Uml exercise

UML Exercise: Automated Teller Machine (ATM),   1. To allow authorized card holders to make transactions,   Brief Summary of Requirements:

  Java program to declares integer array

Write a complete Java program to declares integer array, intArray, and initialize it to {1, 2, 3, 4, 5, 6, 7}.

  Write java program to compute how much federal need to pay

Write a java application to calculate how much federal and state tax you need to pay. The program should accomplish the following task.

  Minimal spanning tree decreasing edge dismissal

Minimal Spanning Tree Decreasing Edge Dismissal, Reverse-delete algorithm. Develop an implementation that computes the MST

  Write down the java code for the bank

Write down the java code for the bank of Fraud. User is presented with menu which looks something like this: 1. Deposit 2. Withdrawal 3. Check Balance 4. Exit.

  Web engineering principles

web application development, Web Engineering methodology, UML-based Web Engineering (UWE), models to the expansion of web applications, Object Oriented Web Solutions (OOWS),Web Modeling Language (WebML) methodology, Object-Oriented Hypermedia Design..

  Java method that contains code to be executed

Write a short Java method that contains code for which it is probably impossible for that code to ever be executed, but your favorite Java compiler does not detect this fact.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd