I need to design a c# program that will prompts the user to enter three characte
ID: 3654239 • Letter: I
Question
I need to design a c# program that will prompts the user to enter three characters, perhaps their initials. Once entered, sort them into ascending order then output that order on the screen.Explanation / Answer
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CSharp2 { class Sort3Char { public static void sort(ref char cA,ref char cB,ref char cC)//makes c the largest -> a smallest { char temp; for (int i = 0; i < 2; i++) { if (cA > cB) { temp = cA; cA = cB; cB = temp; } if (cB > cC) { temp = cB; cB = cC; cC = temp; } } return; } static void Main(string[] args) { char a, b, c; int input; Console.Write("Enter three characters to sort: "); input = Console.Read(); a = Convert.ToChar(input); input = Console.Read(); b = Convert.ToChar(input); input = Console.Read(); c = Convert.ToChar(input); sort(ref a,ref b,ref c); Console.Write("The three characters sorted is: {0}{1}{2}",a,b,c); Console.ReadLine();//stall closing until press enter } } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.