Java

Java.Комментирование. Надо прокомеентировать каждую строку этой программы.

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;
}
}
}
A.
Adidas .
212
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
ЕС
Евгений Ситник
3 830
Лучший ответ
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
Adidas . желательно на русском вообще но спасибо