Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C# program using a Linq statement. Create a string list. Use Console.ReadLine() to collect values of firstName, lastName,street, city, state, zip, save them

Write a C# program using a Linq statement.

Create a string list.

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

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

Create a foreach statement to displaythe information (foreach (var in )).

***Method uppercaseWords() is provided and needs to beincluded entirely in the program:

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);

}

_______________________________________________OUTPUT____________________________________________________

(Note: The following information is provided by theuser.)

Enter firstname: michael

Enter lastname: johnson

Enter street: 999 first street

Enter city: seattle

Enter state: washington

Enter Sipcode: 98433

(The following information is generated automatically.There are upper case letters at the beginning of everyword.)

Costumer’s information:


Michael

Johnson

999 First Street

Seattle

Washington

98433

Press any key to continue...


______________________________________________________________________________________________________________________________

I have also included a similar sample code that can be used as areference for this project:

// Fig. 9.7: LINQWithListCollection.cs

// LINQ to Objects using a List< string>.
using System;
using System.Linq;
using System.Collections.Generic;

public class LINQWithListCollection
{
public staticvoid Main( string[] args)
{
// populate a List of strings
List< string > items= new List< string >();
items.Add( "aQua" ); // add "aQua" tothe end of the List
items.Add( "RusT" ); // add "RusT" tothe end of the List
items.Add( "yElLow" ); // add "yElLow"to the end of the List
items.Add( "rEd" ); // add "rEd" to theend of the List

// convert all strings to uppercase; select those starting with"R"
var startsWithR =
from item in items
let uppercaseString =item.ToUpper()
where uppercaseString.StartsWith( "R" )
orderby uppercaseString
select uppercaseString;

// display query results
foreach ( var item in startsWithR)
Console.Write( "{0} ", item );

Console.WriteLine(); // output end of line

items.Add( "rUbY" ); // add "rUbY" tothe end of the List
items.Add( "SaFfRon" ); // add "SaFfRon"to the end of the List

// display updated query results
foreach ( var item in startsWithR)
Console.Write( "{0} ", item );

Console.WriteLine(); // output end of line
} // end Main
} // end class LINQWithListCollection

Step by Step Solution

3.41 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

using System using SystemLinq using SystemCollectionsGeneric public class LINQWithListCollection pub... 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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Electrical Engineering questions