C# programming Create an application that produces three different outputs using
ID: 3890401 • Letter: C
Question
C# programming
Create an application that produces three different outputs using the same phrase. Select your own favorite popular saying for the phrase. The phrase should first be displayed on a single line. The output should be displayed with white background and black text. Use at least three Write () methods-but display the output on a single line. Next, print the phrase on three separate lines, again using only Write () methods. For your third and final output, print your favorite saying one word per line. Decide which combination of Write () and/or WriteLine () would be the most streamlined approach. Label each output. Following is an example of what the final output would look like using a favorite saying of the author: Output #1 Laugh often, Dream big, Reach for the stars ! Output #2 Laugh often, Dream big, Reach for the stars! Output #3 Laugh often, Dream big, Reach for the stars!Explanation / Answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.White;
Console.Clear();
Console.ForegroundColor = ConsoleColor.Black;
String line = Console.ReadLine();
Console.WriteLine("Output1#1");
Console.Write(line + " ");
String[] words = line.Split(',');
Console.WriteLine("Output1#2");
int count = 0;
foreach (String s in words)
{
count++;
if (count != words.Length)
Console.Write(s+", ");
else
Console.Write(s + " ");
}
words = line.Split(' ');
Console.WriteLine("Output1#3");
foreach (String s in words)
{
Console.Write(s+" ");
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.