0% found this document useful (0 votes)
3 views2 pages

Object Oriented 2java

The Java program prompts the user to input a word and counts the number of vowels and consonants in it. It also attempts to search for song titles that contain the phrase 'pop music' from a predefined list but contains syntax errors and logical issues. The program ends by notifying the user if no matching song titles are found.

Uploaded by

1jdon65ak
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Object Oriented 2java

The Java program prompts the user to input a word and counts the number of vowels and consonants in it. It also attempts to search for song titles that contain the phrase 'pop music' from a predefined list but contains syntax errors and logical issues. The program ends by notifying the user if no matching song titles are found.

Uploaded by

1jdon65ak
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

Scanner;

public class Game {

public static void main(String[] args) {


Scanner scanner = new Scanner([Link]);

[Link]("pot: ");
String word = [Link]().toLowerCase();

int vowels = 0;
int consonants = 0;
for (int i = 0; i < [Link](); i++) {
char ch = [Link](i);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch ==
'u') {
vowels++;
} else if ([Link](ch)) {
consonants++;
}
}
[Link]("Number of vowels: " + vowels);
[Link]("Number of consonants: " + consonants);

String[] song Titles = {


"Bohemian Rhapsody",
"Imagine",
"today",
"just like magic",

/*[Link]("pop music"); {*/


}
String pop = [Link]().toLowerCase();
{

[Link]("Imagine:");
[Link]("Bohemian Rhapsody:") ;
[Link] ("today:") ;
[Link] ( "just like magic:");
[Link] ("pop music:");
}
boolean found = false;
for (String title : songTitles) {
if ([Link]().contains('pop music;')) {
[Link](title);
found = true;
}
}

if(!found){
[Link]("No song titles matching your search query
found.");
}

scanner. Close();

}
}

You might also like