Write a C # console application which contains two classes:
1. The first class “person” contain 4 attributes:
* PersonId which is a private integer.
* Name and Graduation which are public string.
* Age which is a public integer.
And a public method “PersonnalInformation()”. The method should include commands that read the input values for each of the attributes above and then print the input values.
1
Expert's answer
2013-04-08T08:48:11-0400
Class Person using System;
namespace Question_25935 { public class Person { & /// <summary> & /// Default constructor & /// </summary> & public Person() & { & }
& private int PersonId; & & public string Name; & public string Graduation; & public int Age; & & public string PersonnalInformation(int id, string name, string graduation, int age) & { PersonId = id; Name = name; Graduation = graduation; Age = age; return string.Format("Person: {0}, Name: {1}, Graduation: {2}, Age: {3}", PersonId, Name, Graduation, Age); & } & } }
Class Main using System;
namespace Question_25935 { class Program { & public static void Main(string[] args) & { Person person = new Person(); //Create object
Console.Write("Enter value of Person Id: "); var id = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter value of Name: "); var name = Console.ReadLine(); Console.Write("Enter value of Graduation: "); var graduation = Console.ReadLine(); Console.Write("Enter value of Age: "); var age = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(person.PersonnalInformation(id, name, graduation, age)); Console.WriteLine(); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); & } } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment