Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a C# Windows application that reads a five-character string from the user

ID: 3671823 • Letter: C

Question

Create a C# Windows application that reads a five-character string from the user and produces all of its substrings.  For a five-character string, there are five 1-chracter substrings, four 2-character substrings, three 3-character substrings, two 4-character substrings and one 5-character substring.

The following is the GUI of this program:

The user clicks the Go button after he has entered the string.  The program first checks the string’s length.  If it is not exactly 5-character long, a message box will pop up telling the user that the string must have exactly 5 characters:

If the string entered is exactly 5-character long, the program will check whether the five characters are all different.  If some of the characters are the same, the program will use a message box to display an error message:

Uppercase and lowercase letter are considered the same letter.  For example, uppercase ‘P’ and lowercase ‘p’ are considered the same letter and cannot coexist in the string.

If all five characters are different, the program will display all possible substrings in a listbox:

Explanation / Answer

I am giving Console Programm:

/*
* C# Program to List all Substrings in a given String
*/
using System;
namespace mismatch
{
class Program
{
string value, substring;
int j, i;
string[] a = new string[5];
void input()
{
Console.WriteLine("Enter the String : ");
value = Console.ReadLine();
Console.WriteLine("All Possible Substrings of the Given String are :");
for (i = 1; i <=value.Length; i++)
{
for (j = 0; j <= value.Length - i; j++)
{
substring = value.Substring(j, i);
a[j] = substring;
Console.WriteLine(a[j]);
}
}
}
public static void Main()
{
Program pg = new Program();
pg.input();
Console.ReadLine();
}
}
}