Menu
Coddy logo textTech

문자 수 세기

Coddy Dart 여정의 로직 & 흐름 섹션에 포함된 레슨 — 65개 중 52번째.

challenge icon

챌린지

쉬움

텍스트 분석기 기초를 바탕으로, 이제 문자 수 계산 기능을 구현해 보겠습니다. 이 단계에서는 문자, 공백, 문장 부호 및 기타 모든 기호를 포함하여 텍스트의 총 문자 수를 계산합니다.

  1. 이전 설정에서 사용한 textToAnalyze 변수를 사용하세요.
  2. .length 속성을 사용하여 텍스트의 총 문자 수를 계산하세요.
  3. 문자 수를 totalCharacters라는 변수에 저장하세요.
  4. 문자 분석 결과를 아래에 표시된 정확한 형식으로 출력하세요.
  5. 원본 텍스트와 문자 수를 적절한 형식과 함께 표시하세요.

예를 들어, 텍스트 분석기가 "Hello world!"로 설정되었다면, 프로그램은 다음과 같이 출력해야 합니다:

Text Analysis Tool - Character Count
====================================
Analyzing text: "Hello world!"
====================================
Character Analysis Results:
Total characters (including spaces): 12
====================================
Character counting completed successfully.

텍스트 분석기가 "The quick brown fox jumps over the lazy dog"로 설정되었다면, 프로그램은 다음과 같이 출력해야 합니다:

Text Analysis Tool - Character Count
====================================
Analyzing text: "The quick brown fox jumps over the lazy dog"
====================================
Character Analysis Results:
Total characters (including spaces): 43
====================================
Character counting completed successfully.

텍스트 분석기가 "Programming is fun!"으로 설정되었다면, 프로그램은 다음과 같이 출력해야 합니다:

Text Analysis Tool - Character Count
====================================
Analyzing text: "Programming is fun!"
====================================
Character Analysis Results:
Total characters (including spaces): 19
====================================
Character counting completed successfully.

프로그램은 문자열의 .length 속성을 사용하여 문자, 숫자, 공백, 문장 부호 및 기타 모든 기호를 포함한 모든 문자를 계산해야 합니다. 이 문자 수는 향후 레슨에서 더 고급 텍스트 분석을 위한 기초로 사용될 것입니다.

직접 해보기

import 'dart:io';

void main() {
  // Read the input text
  String? inputText = stdin.readLineSync();
  
  // Create the textToAnalyze variable
  String textToAnalyze = inputText ?? '';
  
  // TODO: Write your code below to display the text analysis tool setup
  print('Text Analysis Tool - Setup Complete');
  print('====================================');
  print('Original text loaded for analysis:');
  print('"$textToAnalyze"');
  print('====================================');
  print('Text analyzer is ready to process your data!');
  print('Setup completed successfully.');
}

로직 & 흐름의 모든 레슨