Question
Write a programming code for c#: This is the first in a series of assignment that will read data from a text file and perform
Write a programming code for c#:
This is the first in a series of assignment that will read data from a text file and perform actions on the data.
We'll be reading from a file containing some of the following politician information:
Clinton, Hillary F Democrat
Sanders, Bernie M Democrat
Cruz, Ted M Republican
...
For each line in the file note that we have last name, first name, gender (M/F), and party affiliation.
The goal of this assignment is to build a "salutation" for each politician as follows:
Dear Ms. Hillary Clinton:
~or~
Dear Mr. Ted Cruz:
So, you will need to: a) "flip" the last and first names, and b) use gender to determine whether to use "Ms." or "Mr.".
Print the salutation to the console.
For extra credit, sort the list by political party.
in the file it contains this code:
namespace ConsoleReadInvitations
{
class Program
{
static void Main(string[] args)
{
const string TEXT_FILE = "Invitations.txt";
var linesRead = File.ReadAllLines(TEXT_FILE);
foreach (string line in linesRead)
{
//format salutation as:
//
// Dear Ms. Hillary Clinton:
// ~or~
// Dear Mr. Ted Cruz:
Console.WriteLine(line);
}
Console.ReadLine();
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started