1

Please. help me determine how many small and big letters "s" and the sign "=" occurs in a given text. Print lines in which these characters are missing.

How do I implement validation text and how to recognize the line where there is no such marks

Help with the program. I would be very grateful!

my programm for now. what to do next,

program four;

var
  i : integer;
  MyString : string;
  MyChar : char;
begin
  read( MyString );

  for i := 1 to MyString.Length do
    begin      
      case ( MyString[i] ) of
      'S' : writeln( i );
      's' : writeln( i );
      '=' : writeln( i );
    end;  

  end;
end.
Luchnik
  • 1,067
  • 4
  • 13
  • 31

1 Answers1

1

You need to implement counters to keep track of whether you've found any of the characters or not, so you'll know what to do.

Something like this should get you started:

program four;

var
  i : integer;
  LowerS, UpperS, Equals: Integer;
  MyString : string;
begin
  LowerS := 0;
  UpperS := 0;
  Equals := 0;

  Write('Enter text to scan: ');
  ReadLn( MyString );

  for i := 1 to Length(MyString) do
  begin      
    case ( MyString[i] ) of
      'S' : Inc(UpperS); 
      's' : Inc(LowerS); 
      '=' : Inc(Equals);
    end;  
  end;
  if (UpperS + LowerS + Equals) = 0 then
    WriteLn('No valid characters found')
  else
    WriteLn(Format('S: %d s: %d =: %d', [UpperS, LowerS, Equals]));
  ReadLn;
end.
Ken White
  • 123,280
  • 14
  • 225
  • 444