Create a console program where you will implement arrays and variables that are
ID: 3760534 • Letter: C
Question
Create a console program where you will implement arrays and variables that are needed for this program and will implement the code within Main and any required static methods. Use the following string array declaration: string[] compositeString = { "4for", "2is the", "3week 10 challenge assignment", "1This assignment", "5CIS243" }; Note that each string in the string array has a different length and each has a number as the first character in the array. The number at the beginning of each string indicates the numeric order that the strings should be in. Note that in the output below the order numbers are not displayed. Construct the loops, comparisons, boolean conditionals and any other variables or arrays that will extract each string in the array and arrange the separate strings into a single string which when displayed will produce the output shown below. You should format your output to look exactly like the following: This assignment is the week 10 challenge assignment for CIS243 Press any key to continue . . .
Explanation / Answer
using System;
public class Strings {
public static void Main() {
string[] compositeString = { "4for", "2is the", "3week 10 challenge assignment", "1This assignment", "5CIS243" };
string str="";
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if (compositeString[j][0] == (i+1+48)) {
str += compositeString[j].Substring(1, compositeString[j].Length-1) + " ";
}
}
}
Console.WriteLine(str);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.