Question

In: Computer Science

Create a C# application for Cricket Team that allows you to enter data for player of...

Create a C# application for Cricket Team that allows you to enter data for player of Cricket Team and saves the data to a file named Players.txt. Create a Player class that contains fields for of participant's first name, last name, age, salary and position (wicketkeeper, bawler, striker, midwicket), and To String() method. The fields of records in the file are separated with semicolon (. Expecting sentinel value for ending the process of writing to file is *. E.g. of a record in the file Players.txt: 180000;bawler

Solutions

Expert Solution

Code

using System;
using static System.Console;
using System.IO;

class CricketTeam
{
class Player
{
private string firstName;
private string lasstName;
private string posiotion;
private int salary;
private int age;
public Player(string fn,string ln,int age,int sal, string pos)
{
firstName = fn;
lasstName = ln;
this.age = age;
salary = sal;
posiotion = pos;
}
public override string ToString()
{
return firstName + ";" + lasstName + ";" + age + ";" + salary + ";" + posiotion;
}
}
static void Main(string[] args)
{
string fName, lName, pos;
int salray, age;
string line = "";
  
while (true)
{
Console.Write("Enter player's first name or (stop) to quit: ");
fName = Console.ReadLine();
if (fName == "stop")
break;
Console.Write("Enter player's last name: ");
lName = Console.ReadLine();
Console.Write("Enter player's age: ");
Int32.TryParse(Console.ReadLine(), out age);
Console.Write("Enter player's salary: ");
Int32.TryParse(Console.ReadLine(), out salray);
Console.Write("Enter player's position: ");
pos = Console.ReadLine();
Player p1 = new Player(fName, lName, age, salray, pos);
line += p1.ToString() + "\n";
}
using (System.IO.StreamWriter file =new System.IO.StreamWriter("Players.txt"))
{
file.WriteLine(line);
}
}
}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.


Related Solutions

Create a C# application for Library that allows you to enter data for books and saves...
Create a C# application for Library that allows you to enter data for books and saves the data to a file named Books.txt. Create a Book class that contains fields for title, author, number of pages, and price of the book and ToString() method. The fields of records in the file are separated with asterisk (*). Expecting sentinel value for ending the process of writing to file is "000"
Create an application that allows the user to enter the total for an order and the...
Create an application that allows the user to enter the total for an order and the name of the customer. If the order is less than 500 dollars, the customer gets no discount. If the order is greater than or equal to 500 and less than 1000 dollars, the customer gets a 5 percent discount. If the order is greater than or equal to 1000 dollars, the customer gets a 10 percent discount. The application should display the name of...
Show: Create an application that allows the user to enter the number of calories and fat...
Show: Create an application that allows the user to enter the number of calories and fat grams in a food. The application should display the percentage of the calories that come from fat. If the calories from fat are less than 30% of the total calories of the food, it should also display a message indicating the food is low in fat. One gram of fat has 9 calories, so: Calories from fat = fat grams *9 The percentage of...
Android Studio. Java. Please create an application that -> An activity that allows user to enter...
Android Studio. Java. Please create an application that -> An activity that allows user to enter name, gender, date of birth, state of residence (selected from a pre-defined list: CA, AZ, NV, OR), email address and favorite website. This activity has a button "Show Data" that displays detail entered
Write a C++ console application that allows your user to enter the total rainfall for each...
Write a C++ console application that allows your user to enter the total rainfall for each of 12 months into an array of doubles. The program should validate user input by guarding against rainfall values that are less than zero. After all 12 entries have been made, the program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest rainfall amounts.
Fat Percentage Calculator Create a C++ program that allows the user to enter the number of...
Fat Percentage Calculator Create a C++ program that allows the user to enter the number of calories and fat grams in a food. The application should display the percentage of the calories that come from fat. If the calories from fat are less than 30% of the total calories of the food, it should also display a message indicating the food is low in fat. One gram of fat has 9 calories, so: Calories from fat = fat grams *...
C# Create a console application that prompts the user to enter a regular expression, and then...
C# Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a regular expression...
Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
C# Create an application that asks the user to enter their new password. The password must...
C# Create an application that asks the user to enter their new password. The password must be at least 6 characters long. Develop a custom exception handling case that checks for the password length. (hint: use " .Length " built-in method). If the new password is less than 6 characters long the custom exception should output an error message.
C# & ASP.NET Create a console application that prompts the user to enter a regular expression,...
C# & ASP.NET Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT