Question: Task 8 (10 pts.) The program task8.java given below is an incomplete program. Complete that program, by defining a starts_with_vowel function that satisfies the following

Task 8 (10 pts.) The program task8.java given below is an incomplete program. Complete that program, by

defining a starts_with_vowel function that satisfies the following specs:

starts_with_voweltakesoneargument,calledword. ifwordstartswithavowel,thenstarts_with_vowel(word)returnstrue. otherwise,starts_with_vowel(word)returnsfalse.

IMPORTANT: you are NOT allowed to modify in any way the main function. Hint: our StartWithVowel2.java (given below) program has code that you may find useful, and you

should feel free to reuse. This is an example run of the complete program:

Enter some word, or q to quit: airplane Yes, airplane starts with a vowel.

Enter some word, or q to quit: train No, train does not start with a vowel.

Enter some word, or q to quit: Car No, Car does not start with a vowel.

Enter some word, or q to quit: Elephant Yes, Elephant starts with a vowel.

Enter some word, or q to quit: q Exiting...

StartWithVowel2.java

 // This is a program that: // - asks the user to enter a string // - prints if the first letter of that string is a vowel or not. // // This version checks for both lower-case and upper-case vowels. 
 import java.util.Scanner; 
 public class StartsWithVowel2 { 
 public static void main(String[] args) { 
 Scanner in = new Scanner(System.in); System.out.printf("Enter some word: "); String word = in.next(); 
char c = word.charAt(0); 
if ("aeiouAEIOU".indexOf(c)!= -1) { 
 System.out.printf("Your word starts with a vowel "); } 

else {

 System.out.printf("Your word does not start with a vowel "); } 

} }

task8.java

import java.util.Scanner; 
public class task8 { 
 public static void main(String[] args) { 
 Scanner in = new Scanner(System.in); 
 while (true) { 
 System.out.printf("Enter some word, or q to quit: "); String word = in.next(); if (word.toLowerCase().equals("q")) { 
 System.out.printf("Exiting... "); 
 System.exit(0); } 
 boolean result = starts_with_vowel(word); if (result == true) { 
 System.out.printf("Yes, %s starts with a vowel. ", word); } 

else {

 System.out.printf("No, %s does not start with a vowel. ", 

word); }

} }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!