import java.util.Scanner;
public class g1 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
String string1;
System.out.println("Введи слово");
string1 = sc.nextLine();
string1 = string1.toLowerCase();
int glasnie = 0;
int coglasnie = 0;
for (String retval : string1.split(" ")) {
for (int i = 0; i < retval.length(); i++) {
char ch = retval.charAt(i);
if (ch == 'а' || ch == 'е' || ch == 'и' || ch == 'о' || ch == 'у' || ch == 'я' || ch == 'ё' || ch == 'э') {
glasnie++;
} else {
coglasnie++;
}
}System.out.println(retval.substring(0, 1).toUpperCase() + retval.substring(1) + " - это слово имеет " + glasnie
+ " гласные и " + +coglasnie + " согласные");
glasnie = 0;
coglasnie = 0;
}
}
}
Java
Java.Комментирование. Надо прокомеентировать каждую строку этой программы.
mport java.util.Scanner; //Importing Scanner to be able to read streams
public class g1 { //Class definition
public static void main(String args[]) { //Entry point
Scanner sc = new Scanner(System.in); //Java perversion of having a reader to read std. input
String string1; //Variable definition
System.out.println("Введи слово"); //Surprisingly, we don't need any kind of "writer" to be able to write to std. output!
string1 = sc.nextLine(); //Reading a line from the reader
string1 = string1.toLowerCase(); //Converting the read string into lowerecase
int glasnie = 0; //Vowel counter
int coglasnie = 0; //Consonant counter
for (String retval : string1.split(" ")) { //Splitting string into words by spaces.
for (int i = 0; i < retval.length(); i++) { //Scanning current word
char ch = retval.charAt(i); //Taking a character from current word
if (ch == 'а' || ch == 'е' || ch == 'и' || ch == 'о' || ch == 'у' || ch == 'я' || ch == 'ё' || ch == 'э') { //Checking for a vowel, not counting ю
glasnie++; //Vowel counter increment
} else { //Else
coglasnie++; //Consonant counter increment (actually, other symbols and ю are also considered consonant)
}
} System.out.println(retval.substring(0, 1).toUpperCase() + retval.substring(1) + " - это слово имеет " + glasnie
+ " гласные и " + +coglasnie + " согласные"); //Vowel/consonant stats for current word
glasnie = 0; //Nullifying counters for next loop instead of re-defining - whoever wrote this must have been shot with a slingshot in his early childhood.
coglasnie = 0;//Nullifying counters for next loop instead of re-defining - whoever wrote this must have been shot with a slingshot in his early childhood.
} //Closing a block
} //Closing a block
} //Closing a block
public class g1 { //Class definition
public static void main(String args[]) { //Entry point
Scanner sc = new Scanner(System.in); //Java perversion of having a reader to read std. input
String string1; //Variable definition
System.out.println("Введи слово"); //Surprisingly, we don't need any kind of "writer" to be able to write to std. output!
string1 = sc.nextLine(); //Reading a line from the reader
string1 = string1.toLowerCase(); //Converting the read string into lowerecase
int glasnie = 0; //Vowel counter
int coglasnie = 0; //Consonant counter
for (String retval : string1.split(" ")) { //Splitting string into words by spaces.
for (int i = 0; i < retval.length(); i++) { //Scanning current word
char ch = retval.charAt(i); //Taking a character from current word
if (ch == 'а' || ch == 'е' || ch == 'и' || ch == 'о' || ch == 'у' || ch == 'я' || ch == 'ё' || ch == 'э') { //Checking for a vowel, not counting ю
glasnie++; //Vowel counter increment
} else { //Else
coglasnie++; //Consonant counter increment (actually, other symbols and ю are also considered consonant)
}
} System.out.println(retval.substring(0, 1).toUpperCase() + retval.substring(1) + " - это слово имеет " + glasnie
+ " гласные и " + +coglasnie + " согласные"); //Vowel/consonant stats for current word
glasnie = 0; //Nullifying counters for next loop instead of re-defining - whoever wrote this must have been shot with a slingshot in his early childhood.
coglasnie = 0;//Nullifying counters for next loop instead of re-defining - whoever wrote this must have been shot with a slingshot in his early childhood.
} //Closing a block
} //Closing a block
} //Closing a block
import java.util.Scanner; //Importing Scanner to be able to read streams
public class g1 { //Class definition
public static void main(String args[]) { //Entry point
Scanner sc = new Scanner(System.in); //Java perversion of having a reader to read std. input
String string1; //Variable definition
System.out.println("Введи слово"); //Surprisingly, we don't need any kind of "writer" to be able to write to std. output!
string1 = sc.nextLine(); //Reading a line from the reader
string1 = string1.toLowerCase(); //Converting the read string into lowerecase
int glasnie = 0; //Vowel counter
int coglasnie = 0; //Consonant counter
for (String retval : string1.split(" ")) { //Splitting string into words by spaces.
for (int i = 0; i < retval.length(); i++) { //Scanning current word
char ch = retval.charAt(i); //Taking a character from current word
if (ch == 'а' || ch == 'е' || ch == 'и' || ch == 'о' || ch == 'у' || ch == 'я' || ch == 'ё' || ch == 'э') { //Checking for a vowel, not counting ю
glasnie++; //Vowel counter increment
} else { //Else
coglasnie++; //Consonant counter increment (actually, other symbols and ю are also considered consonant)
}
}System.out.println(retval.substring(0, 1).toUpperCase() + retval.substring(1) + " - это слово имеет " + glasnie
+ " гласные и " + +coglasnie + " согласные"); //Vowel/consonant stats for current word
glasnie = 0; //Nullifying counters for next loop instead of re-defining - whoever wrote this must have been shot with a slingshot in his early childhood.
coglasnie = 0;//Nullifying counters for next loop instead of re-defining - whoever wrote this must have been shot with a slingshot in his early childhood.
} //Closing a block
} //Closing a block
} //Closing a block
public class g1 { //Class definition
public static void main(String args[]) { //Entry point
Scanner sc = new Scanner(System.in); //Java perversion of having a reader to read std. input
String string1; //Variable definition
System.out.println("Введи слово"); //Surprisingly, we don't need any kind of "writer" to be able to write to std. output!
string1 = sc.nextLine(); //Reading a line from the reader
string1 = string1.toLowerCase(); //Converting the read string into lowerecase
int glasnie = 0; //Vowel counter
int coglasnie = 0; //Consonant counter
for (String retval : string1.split(" ")) { //Splitting string into words by spaces.
for (int i = 0; i < retval.length(); i++) { //Scanning current word
char ch = retval.charAt(i); //Taking a character from current word
if (ch == 'а' || ch == 'е' || ch == 'и' || ch == 'о' || ch == 'у' || ch == 'я' || ch == 'ё' || ch == 'э') { //Checking for a vowel, not counting ю
glasnie++; //Vowel counter increment
} else { //Else
coglasnie++; //Consonant counter increment (actually, other symbols and ю are also considered consonant)
}
}System.out.println(retval.substring(0, 1).toUpperCase() + retval.substring(1) + " - это слово имеет " + glasnie
+ " гласные и " + +coglasnie + " согласные"); //Vowel/consonant stats for current word
glasnie = 0; //Nullifying counters for next loop instead of re-defining - whoever wrote this must have been shot with a slingshot in his early childhood.
coglasnie = 0;//Nullifying counters for next loop instead of re-defining - whoever wrote this must have been shot with a slingshot in his early childhood.
} //Closing a block
} //Closing a block
} //Closing a block
Adidas .
желательно на русском вообще но спасибо
Похожие вопросы
- Как сделать так,что бы минимальный элемент каждой строки оказался в начале? Что неправильно сделала
- Работа со строками Java Разработать программу, которая вводит строку и находит все слова указанной длины n (n вводится).
- Подскажите пожалуйста, как в данном коде Java сделать так, чтоб при нажатии цифры 3 программа завершала свою работу?
- Помогите разобрать программу java
- Написать программу на языке java
- Как создать программу (Java), чтобы была не консольной, а с интерфейсом GUI
- Всем привет. Помогите плз. Мне нужна помощь тех кто действительно хорошо знает Java т. к мне нужно выбрать один из курсов
- Помогите доделать код на java. В форму пользователь вводит символ, который нужно заменить на #.
- Не выводит изображение в JAVA
- Java проблема с рефлексией.