Question

Create a class “Person” which includes first name, last name, age, gender, salary, and haveKids (Boolean)...

Create a class “Person” which includes first name, last name, age, gender, salary, and haveKids (Boolean) variables. You have to create constructors and properties for the class.

Create a “MatchingDemo” class. In the main function, the program reads the number of people in the database from a “PersonInfo.txt” file and creates a dynamic array of the object. It also reads the peoples information from “PersonInfo.txt” file and saves them into the array.

In C#

Give the user the ability to search gender, age, salary, or haveKids and then display the result in descending order. If there is no matching result, the program displays “No Matching Found”

Create a search function with the parameters for search that one person the user wanted.

Create a sorting function to display the result in descending order.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Check with the below code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace MatchFinderConsole
{
class MatchingDemo
{
static void Main(string[] args)
{
List<Person> listArray = new List<Person>();

using (StreamReader reader = new StreamReader("..\\..\\PersonInfo.txt"))
{
while (true)
{
string line = reader.ReadLine();
if (line == null)
{
break;
}

string []tempAr;
tempAr=line.Split(',');

Person obj = new Person();
obj.firstName = tempAr[0];
obj.lastName = tempAr[1];
obj.age = Convert.ToInt16(tempAr[2]);
obj.gneder = tempAr[3];
obj.salary = Convert.ToDouble(tempAr[4]);
obj.haveKids = Convert.ToBoolean(tempAr[5]);

listArray.Add(obj);

}
}


//Filter by age

var newList = listArray.OrderByDescending(x => x.age)
.ThenBy(x => x.age)
.ToList();


//Filter by salary


var newList1 = listArray.OrderByDescending(x => x.salary)
.ThenBy(x => x.salary)
.ToList();

}
}
class Person
{
public string firstName;
public string lastName;
public int age;
public string gneder;
public double salary;
public bool haveKids;

}


}

Please rate it if the above solution helps you in any way or if you have any concerns comment it, I will help you through again.

Add a comment
Know the answer?
Add Answer to:
Create a class “Person” which includes first name, last name, age, gender, salary, and haveKids (Boolean)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON*************** Create a Person Class that: Accepts First Name, Last Name, Age, and Gender Has a...

    PYTHON*************** Create a Person Class that: Accepts First Name, Last Name, Age, and Gender Has a method that adds all persons Validate all input, not left empty for First Name, Last Name, Gender and numeric for age and throw an exception if it does not validate within the class. Create a Student Class that: Inherits the Person Class Accepts GPA Validate GPA (>= 0 and <= 4.0) and throw exception if it does not validate within the class. Has methods...

  • *** C++ *** Create a class called Student that contains a first name ( string) and...

    *** C++ *** Create a class called Student that contains a first name ( string) and an student id number (type long).     1. Include a member function called get_data( ) to get data from the user for insertion into the object,     2. Also include a function called display_data( ) that displays the student data. Then write a complete program that uses the class to do some computation. Your main function, main( ), should create a Dynamic Array of...

  • python code? 1. Create a class called Person that has 4 attributes, the name, the age,...

    python code? 1. Create a class called Person that has 4 attributes, the name, the age, the weight and the height [5 points] 2. Write 3 methods for this class with the following specifications. a. A constructor for the class which initializes the attributes [2.5 points] b. Displays information about the Person (attributes) [2.5 points] c. Takes a parameter Xage and returns true if the age of the person is older than Xage, false otherwise [5 points] 3. Create another...

  • Visual C# Homework 2 You are to write a program which will create a class called...

    Visual C# Homework 2 You are to write a program which will create a class called Student Each student has a name age height and weight. These variables should be declared as private. Create the correct constructors and functions. In the main, you will create 5 students. Input the data for the 5 students from a file which already has information in it. Name the file “Information.txt”. After setting up all the data, it is time to sort based on...

  • C++ There is a class called Person which has name and age as private variables. Another...

    C++ There is a class called Person which has name and age as private variables. Another class called Student, which is derived from person with gpa and id as variables. name is a string, age and id are integers and gpa is a double... All of them are private variables. age, gpa and id should be generated randomly when the object is created with the following ranges: age 20 to 32 gpa 0.0 to 4.0 // this one is tricky...

  • Using C++ create a class called person. A person can have a name, address, age. For...

    Using C++ create a class called person. A person can have a name, address, age. For this class create a default constructor and parameterized constructor. Show the main as int main() { } ----------------------------------------------------- Show how you will define the class and call it in the main. Only create two instances/objects in main using the two created constructors.

  • create a Person class with two fields (name(String), age(int)) create all the required methods such as...

    create a Person class with two fields (name(String), age(int)) create all the required methods such as the accessors, mutators, toString(),constructors etc. Use the comparable interface and implement the compareTo method such that the person objects can be compared and sorted according to their age.

  • answer in c# console application. File l/O Create a Person class (firstName, lastName, phoneNumber, gender (Use...

    answer in c# console application. File l/O Create a Person class (firstName, lastName, phoneNumber, gender (Use radioButtons for gender in the GUI) ) Create a List<Person> Create a GUI that will collect the Person information from the user and have 3 buttons: Add, Display, Read. Add button Add the just created person to List<Person>, and append to a text file Display button > print out all persons currently in the List<Person> in a label in a visually attractive way Read...

  • Write a java program to create a student file which includes first name, last name, and...

    Write a java program to create a student file which includes first name, last name, and GPA. Write another Java program to open the students file. Display the students list and calculate the average GPA of the class.  

  • About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which...

    About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which has private data members for name, age, gender, and height. You MUST use this pointer when any of the member functions are using the member variables. Implement a constructor that initializes the strings with an empty string, characters with a null character and the numbers with zero. Create getters and setters for each member variable. Ensure that you identify correctly which member functions should...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT