Код: Выделить всё
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
String userText;
int numPun = 0; //number of punctiation and spaces
// Add more variables as needed
userText = scnr.nextLine(); // Gets entire line, including spaces.
for (int i = 0; i < userText.length(); i++){
if ((userText.charAt(i) != ' ') && (userText.charAt(i) != ',') && (userText.charAt(i) != '.'));{
numPun++;
}
}
System.out.println(numPun);
}
}
Подробнее здесь: https://stackoverflow.com/questions/667 ... riods-java