Quotes help make search much faster. Example: "Practice Makes Perfect"

Tuesday, September 3, 2019

Codecademy Manipulate Strings 7/8


// Sample Solution
using System;

namespace MovieScript
{
  class Program
  {
    static void Main(string[] args)
    {
      // Script line
      string script = "Close on a portrait of the HANDSOME PRINCE -- as the BEAST'S giant paw slashes it.";

      // Get camera directions
      int charPosition = script.IndexOf("Close");
      int length = "Close on".Length;
      string cameraDirections = script.Substring(charPosition, length);

      // Get scene description
      charPosition = script.IndexOf("a portrait");
      string sceneDescription = script.Substring(charPosition);

      // Make camera directions uppercase
cameraDirections = cameraDirections.ToUpper();

      // Make scene description lowercase
sceneDescription = sceneDescription.ToLower();

      // Print results
Console.WriteLine(cameraDirections);
      Console.WriteLine(sceneDescription);
    }
  }
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts