import java util. Scanner; public class Lab7 public static void main (String[ ar
ID: 3826584 • Letter: I
Question
import java util. Scanner; public class Lab7 public static void main (String[ args) //PART 1 Determine and print how many of each vowels appear in a string Scanner scan new Scanner System. in. System out.println ("Enter a string or type N"quitV" to exit:"); String line scan. nextLine //convert all characters to lower cases line J line toLowerCase while line equals "quit") false) //counter is used to count the number of vowels int counter 0; //Step 1-a: Complete the following for loop so that //the index i goes from the beginning of the string to the end //Hint: use length method for (int i 0; //Step1-b Complete the following if statement to check if //character is one of vowels a,e, i, o or u //Hint. use charAt method if (line.charAt (i) 'a' counter System out.println("The string line contains counter vowel (s)"); System out. println ("Enter a string or type "quit to exit line scan. nextLine //convert all characters to lower cases line line .toLowerCase System out.println ("InThe following is PART 2 "); this will create a new lineExplanation / Answer
Lab7.java
import java.util.Scanner;
public class Lab7 {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
System.out.println("Enter a String or type "quit" to exit:");
String line=scan.nextLine();
line=line.toLowerCase();
while(line.equals("quit")==false)
{
//counter is used to count the number of vowels
int counter =0;
for(int i=0;i<line.length();i++)
{
if(line.charAt(i)=='a' ||
line.charAt(i)=='e'||
line.charAt(i)=='i'||
line.charAt(i)=='o'||
line.charAt(i)=='u')
{
counter++;
}
}
System.out.println("the String "+line+" contains "+counter+ " vowels(s)");
System.out.println("Enter a String or type "quit" to exit:");
line=scan.nextLine();
line=line.toLowerCase();
}
System.out.println("The following is part 2 ");
}
}
___________________
output:
Enter a String or type "quit" to exit:
hello how are you williams?
the String hello how are you williams? contains 10 vowels(s)
Enter a String or type "quit" to exit:
quit
_______________________
Lab.java
public class Lab {
public static void main(String[] args) {
for(int i=1;i<=5;i++)
{
for(int j=5;j>=i;j--)
{
System.out.print(" ");
}
for(int j=1;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
___________________
output:
*
**
***
****
*****
_____________Thank You
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.