C
C#•13mo ago
RANI

YO I NEED HELP writing a code need advice not for u to write it for me

write me a c# program that get 3 latters and tell if they are by the order like abc if they are backward like cba or if they are random like ami
17 Replies
RANI
RANIOP•13mo ago
help mb worng quition i need a c# program that get 3 latters and tell if they are by the order like abc if they are backward like cba or if they are random like ami
Buddy
Buddy•13mo ago
We won't write it for you $details
MODiX
MODiX•13mo ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
Buddy
Buddy•13mo ago
Specifically in this case, please post your code.
RANI
RANIOP•13mo ago
i need how to like do the letter shit i know the rest
ZacharyPatten
ZacharyPatten•13mo ago
1. What does "get 3 letters mean"? Allow the user to input 3 letters in the console? Randomly Generate 3 letters? etc. 2. Are there only 3 possible outputs? in-order, reverse-order, no-order?
RANI
RANIOP•13mo ago
like u get abc and program need to say u get 3 letter and that the only 3 outpot
ZacharyPatten
ZacharyPatten•13mo ago
how do you get three letters? do you already have that code written? are you doing Console.ReadLine() to get the letters? can you share your code
RANI
RANIOP•13mo ago
in put are 3 letters output in-order, reverse-order, no-order
ZacharyPatten
ZacharyPatten•13mo ago
can you share your current code? that will be the easiest way for us to help $codegif
RANI
RANIOP•13mo ago
using System; class Program { static void Main() { //need to get letter and do the order part if (first < second && second < third) { Console.WriteLine("The letters are in ascending order (like abc)."); } else if (first > second && second > third) { Console.WriteLine("The letters are in descending order (like cba)."); } else { Console.WriteLine("The letters are in random order."); } } else { Console.WriteLine("Invalid input. Please enter exactly three letters."); } } }
ZacharyPatten
ZacharyPatten•13mo ago
you should start with the //need to get letter and do the order part it will be easier to test the rest of your code if you do that first is that what you are asking for help on? because your logic of your if statements looks like you are on the right track at first glance 🙂
RANI
RANIOP•13mo ago
Console.Write("numer 1:"); int num3 = int.Parse(Console.ReadLine()); Console.Write(numer 2"); int num2 = int.Parse(Console.ReadLine()); Console.Write("number 3"); int num1= int.Parse(Console.ReadLine()); to get number and how to do the output how to like do the order shit?
ZacharyPatten
ZacharyPatten•13mo ago
you don't necessarily need to do the int.Parse you do that if you need to convert he value into an integer you don't sound like you need to do that for your code
RANI
RANIOP•13mo ago
that like to get the number how to do the order
ZacharyPatten
ZacharyPatten•13mo ago
you are so close that I'll give you this possible example
Console.Write("Provide 3 characters: ");
string input = Console.ReadLine() ?? "";
input = input.Trim();
if (input.Length != 3)
{
Console.WriteLine("Invalid Input.");
return;
}
char first = input[0];
char second = input[1];
char third = input[2];

Console.WriteLine($"You provided chars '{first}', '{second}', and '{third}'");
Console.Write("Provide 3 characters: ");
string input = Console.ReadLine() ?? "";
input = input.Trim();
if (input.Length != 3)
{
Console.WriteLine("Invalid Input.");
return;
}
char first = input[0];
char second = input[1];
char third = input[2];

Console.WriteLine($"You provided chars '{first}', '{second}', and '{third}'");
that example jsut has the user provide all 3 characters in one Console.ReadLine and it splits the characters into seperate variables from the input string you can get individual chars from a string using the indexer. myString[...] where ... is the index of the char to get from the string input.Trim() is a helper method that will remove white space on the front and end of the string, so if the user inputs " abc " instead of just "abc" the code will still allow it you don't necessarily need to include the .Trim() if you don't want to. it is just generally a good practice
Want results from more Discord servers?
Add your server