Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a string List. 2. Use Console.ReadLine() to collect values of firstName, lastName, street, city, state, zip, save them to List. 3. Write a

1. Create a string List.

2. Use Console.ReadLine() to collect values of firstName, lastName, street, city, state, zip, save them to List.

3. Write a simple Linq statement, call method UppercaseWords() to change first letter to uppercase.

4. Create a foreach statment to display the information.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public static string UppercaseWords(string value) { char[] array = value.ToCharArray(); if (array.Length >= 1) { if (char.IsLower(array[0])) { array[0] = char.ToUpper(array[0]); } } for (int i = 1; i < array.Length; i++) { if (array[i - 1] == ' ') { if (char.IsLower(array[i])) { array[i] = char.ToUpper(array[i]); } } } return new string(array); }

I have the correct code, but for some reason the input data is not displaying after it is run.

Here is my code:

using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions;

public class Program { public static void Main(string[] args) { List items = new List(); Console.WriteLine("Enter first name: "); string Fname = Console.ReadLine(); items.Add(Fname); Console.WriteLine("Enter last name: "); string Lname = Console.ReadLine(); items.Add(Lname); Console.WriteLine("Enter street: "); string Street = Console.ReadLine(); items.Add(Street); Console.WriteLine("Enter City: "); string city = Console.ReadLine(); items.Add(city); Console.WriteLine("Enter state: "); string State = Console.ReadLine(); items.Add(State); Console.WriteLine("Enter Sip code: "); string Sip = Console.ReadLine(); items.Add(Sip);

foreach (var item in items) { Console.WriteLine(UpperCaseMethod(item.ToLower())); }

} public static string UpperCaseMethod(string input) { if (String.IsNullOrEmpty(input)) throw new ArgumentException("ARGH!"); return input.First().ToString().ToUpper() + input.Substring(1); }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions