C# help
i having trouble doing in c# want me please?
mission: write program alphabetize list of last names. user input undetermined number of last names. program display number of names entered , alphabetized lists of names in ascending (a-z) , descending (z-a) order.
program store names in arraylist object. use various arraylist properties , methods implement program requirements.
sample output:
enter last name: roberts
keep going? (y/n): y
enter last name: delay
keep going? (y/n): y
enter last name: foreman
keep going? (y/n): y
enter last name: ganguly
keep going? (y/n): n
4 last names entered
names in ascending order
delay
foreman
ganguly
names in descending order
roberts
ganguly
foreman
delay
tips
best practices: don't try write @ time! first, write outline in comments based on requirements , pseudocode. then, work on instantiating arraylist object, followed implementing loop user input. always, keep things simple , implement incrementally. review list of arraylist methods , properties in textbook , experiment ones think you'll need.
pseudocode
main function
instantiate arraylist object
loop last names, until user wants quit
add each last name arraylist
display count of last names
sort arraylist
loop display names
reverse order of arraylist
loop display names
mission: write program alphabetize list of last names. user input undetermined number of last names. program display number of names entered , alphabetized lists of names in ascending (a-z) , descending (z-a) order.
program store names in arraylist object. use various arraylist properties , methods implement program requirements.
sample output:
enter last name: roberts
keep going? (y/n): y
enter last name: delay
keep going? (y/n): y
enter last name: foreman
keep going? (y/n): y
enter last name: ganguly
keep going? (y/n): n
4 last names entered
names in ascending order
delay
foreman
ganguly
names in descending order
roberts
ganguly
foreman
delay
tips
best practices: don't try write @ time! first, write outline in comments based on requirements , pseudocode. then, work on instantiating arraylist object, followed implementing loop user input. always, keep things simple , implement incrementally. review list of arraylist methods , properties in textbook , experiment ones think you'll need.
pseudocode
main function
instantiate arraylist object
loop last names, until user wants quit
add each last name arraylist
display count of last names
sort arraylist
loop display names
reverse order of arraylist
loop display names
a naive implementation looks this:
var names = new list<string>(); { console.write("\nenter name: "); names.add(console.readline()); console.write("keep going? (y/n)"); } while (console.readkey().keychar == 'y'); console.writeline( "\n{0} names entered." + "\nnames in ascending order\n"); names.sort(); foreach (var name in names) { console.writeline(name); } console.writeline("\nnames in descending order\n"); names.reverse(); foreach (var name in names) { console.writeline(name); }
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment