문자열을 가져 와서 대문자, 소문자, 숫자, 마침표, 쉼표, 공백 및 기타 기호를 출력 할 수 있기를 원합니다. 대부분의 코드는 끝났지 만 문제가있는 부분에 대해서는 주석을 달았습니다. 나는 이것을 할 수 없다. 그리고 그것은 주간의 더 좋은 부분을 위해 나를 난처하게했다! 어떤 도움을 주셔서 감사합니다! char
String
배열로 변환하여문자열을 가져와 출력하는 방법 : 공백, 대문자, 소문자 등
import java.util.*;
public class JavaPractice
{
public static void main(String[] args)
{
//declarations
Scanner keyboard = new Scanner(System.in);
char tryAgain = 'n';
char linechar = ' ';
String lineText;
int uppercase = 0;
int lowercase = 0;
int digits = 0;
int periods = 0;
int commas = 0;
int blanks = 0;
int others = 0;
do
{
// initialize categories
uppercase = 0;
lowercase = 0;
digits = 0;
periods = 0;
commas = 0;
blanks = 0;
others = 0;
// user input
System.out.println("Enter a line of text:");
lineText = keyboard.nextLine();
// This is where I would like to count the number of spaces, uppercase ETC where I am having the most trouble
// print output
System.out.println("Uppercase:") + (uppercase);
System.out.println("Lowercase:") + (lowercase);
System.out.println("Digits:") + (digits)
System.out.println("Periods:") + (periods);
System.out.println("Commas:") + (commas);
System.out.println("Blanks:") + (blanks);
System.out.println("Other Symbols":) + (others);
// try again
System.out.println("Would you like to try again y/n?");
tryAgain = keyboard.nextLine().charAt(0);
} while (tryAgain == 'y' || tryAgain == 'Y'); //end while loop
System.out.println("GoodBye");
} //end main()
} //end JavaPractice
* 어떻게 * 문제가 있는지 말할 수 있습니다. – awksp
더 구체적으로 말하자면, 실제로 무언가를 코딩하려고 시도하고 빈 영역으로 오지 않으려 고 할 수 있습니다 ... – awksp