Question

In: Computer Science

In C#, declare structure named Person. The structure should have the following attributes of first name,...

In C#, declare structure named Person. The structure should have the following attributes of first name, last name, zip code, and phone number.

Solutions

Expert Solution

C# Program

using System;
struct Person { /* declaring structure */
   public string firstname; /*declaring firstname as string */
   public string lastname; /* declaring structure last name as string*/
   public int zipcode; /* declaring zipcode as integer type */
   public int phonenumber; /* declaring phone number as integer type */
}
public class Program
{
   public static void Main()
   {
       Person p; /* declaring p of person type */
       /* initializing values */
       p.firstname="John";
       p.lastname="Jackson";
       p.zipcode=658523;
       p.phonenumber=85965544;
       /* printing details */
       Console.WriteLine( "Name :"+p.firstname+" "+p.lastname);
       Console.WriteLine( "Zipcode :"+p.zipcode);
       Console.WriteLine( "Phonenumber:"+p.phonenumber);
      
      
   }
}

Screenshot

Output

If you find this useful, please rate positive , thankyou


Related Solutions

Write a class named Person with data attributes for a person’s first name, last name, and...
Write a class named Person with data attributes for a person’s first name, last name, and telephone number. Next, write a class named Customer that is a subclass of the Person class. The Customer class should have a data attribute for a customer number and a Boolean data attribute indicating whether the customer wishes to be on a calling list. Demonstrate an instance of the Customer class in a simple program. Using python
In C++ ============================================================EXERCISE 2 PROBLEM SET============================================================ 1) Declare a structure named TempScale , with the following...
In C++ ============================================================EXERCISE 2 PROBLEM SET============================================================ 1) Declare a structure named TempScale , with the following members:fahrenheit: a doublecentigrade: a doubleNext, declare a structure named Reading , with the following members:windSpeed: an inthumidity: a doubletemperature: a TempScale str ucture variableNext define a Reading structure variable. ------------------------------------------------------------ 2) Write statements that will store the following data inthe variable you defined in Problem 1:Wind Speed: 37 mphHumidity: 32%Fahrenheit temperature: 32 degreesCentigrade temperature: 0 degrees ------------------------------------------------------------ 3) Write a function called showReading. It...
Declare a string variable and initialize it with your first name ( in C++)
Declare a string variable and initialize it with your first name ( in C++)
CODE IN C++ PLEASE Create a structure (object) named Person that has the following characteristics: •...
CODE IN C++ PLEASE Create a structure (object) named Person that has the following characteristics: • full name • age • family members full names represent by an array of size 10. Write a program that creates an array of Person of size 5. Populate the array of objects with the information given by user input according to the following specifications: • With input from the user i) Populate only 3 positions of the array of Person object. ii) Populate...
Design a class named Pet, which should have the following fields: Name – The name field...
Design a class named Pet, which should have the following fields: Name – The name field holds the name of a pet. Type – The type field holds the type of animal that is the pet. Example values are “Dog”, “Cat”, and “Bird”. Age – The age field holds the pet’s age. The Pet class should also have the following methods: setName – The setName method stores a value in the name field. setType – The setType method stores a...
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last...
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyEmployee that inherits from the Employee class.   HourEmployee must use the inherited parent class variables and add in HourlyRate and HoursWorked. Your HourEmployee class should contain a constructor that calls the constructor from the...
In C# thanks please, Design a class named Person with properties for holding a person’s name,...
In C# thanks please, Design a class named Person with properties for holding a person’s name, address, and telephone number. Design a class named Customer, which is derived from the Person class. The Customer class should have the variables and properties for the customer number, customer email, a spentAmount of the customer’s purchases, and a Boolean variable indicating whether the customer wishes to be on a mailing list. It also includes a function named calcAmount that calculates the spentAmount. All...
declare a struct named matrix and typedef the struct to type name Matrix. A mathematical matrix...
declare a struct named matrix and typedef the struct to type name Matrix. A mathematical matrix is a two-dimensional, rectangular data structure. The matrix struct should have three fields (in this order): an unsigned variable named "rows", an unsigned variable named "columns", and a pointer to a pointer to double (i.e. double**) named "data". (Code #including matrix.h should be able to declare Matrix variables.) In matrix.c, implement the create_matrix function. The Matrix should be filled with 0.0 values. data[i] should...
Design and develop a class named Person in Python that contains two data attributes that stores...
Design and develop a class named Person in Python that contains two data attributes that stores the first name and last name of a person and appropriate accessor and mutator methods. Implement a method named __repr__ that outputs the details of a person. Then Design and develop a class named Student that is derived from Person, the __init__ for which should receive first name and last name from the class Person and also assigns values to student id, course, and...
Using C#: Write a class named Employee that has the following properties: Name - The Name...
Using C#: Write a class named Employee that has the following properties: Name - The Name property holds the employee's name IdNumber - The IdNumber property holds the employee's ID number Department - The Department property holds the name of the department in which the employee works Position - The Position property holds the employee's job title The class should have the following overloaded constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT